/
2711.test.cpp
48 lines (44 loc) · 940 Bytes
/
2711.test.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// verification-helper: PROBLEM http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2711
#include <bits/stdc++.h>
using namespace std;
#define call_from_test
#include "../../string/suffixarray.cpp"
#include "../../string/longestcommonprefix.cpp"
#undef call_from_test
signed main(){
cin.tie(0);
ios::sync_with_stdio(0);
string s;
cin>>s;
LongestCommonPrefix lcp(s);
int q;
cin>>q;
for(int i=0;i<q;i++){
int l,r,t;
cin>>l>>r>>t;
l--;
int x=lcp.lcp(l,l+t);
if(l+t+x+1>=r){
cout<<"Yes\n";
continue;
}
int y=lcp.lcp(l+x+1,l+t+x+1);
if(l+t+x+1+y>=r){
cout<<"Yes\n";
continue;
}
if(l+x+1+y<l+t){
cout<<"No\n";
continue;
}
int z=lcp.lcp(l+x+1+y+1,l+t+x+1+y+1);
if(l+t+x+1+y+1+z<r){
cout<<"No\n";
continue;
}
if(x+t==x+1+y&&s[l+x]==s[l+x+t+t]) cout<<"Yes\n";
else cout<<"No\n";
}
cout<<flush;
return 0;
}