#include <bits/stdc++.h>
using namespace std;
int main()
{
int n, q;
cin >> n >> q;
string s;
cin >> s;
bool flag[n] = {true}, flag2[n] = {true};
int a, b, p, num = 0, c = 0;
while (q--)
{
cin >> a >> b;
a -= 1;
b -= 1;
p = b - a + 1;
string t;
t = s.substr(a, p);
// cout << s << endl;
// cout << t << endl;
for (int i = 0; i < a; i++)
{
if (s[i] == t[0])
{
num++;
// cout << i << "&&&&";
break;
}
}
for (int i = b + 1; i < n; i++)
{
if (s[i] == t[p - 1])
{
num++;
// cout << i << "&&&&";
break;
}
}
if (num >= 1)
{
cout << "YES" << endl;
}
else
{
cout << "NO" << endl;
}
num = 0;
}
}
标签:子串,std,string,int,cin,序列,true,cout
From: https://blog.csdn.net/2301_80470126/article/details/144108868