fork download
  1. #include<bits/stdc++.h>
  2. #define ll long long int
  3. using namespace std;
  4.  
  5. int main () {
  6.  
  7. ll n;
  8. cin>>n;
  9.  
  10. string s;
  11. cin>>s;
  12.  
  13. ll m;
  14. cin>>m;
  15.  
  16. while(m--){
  17.  
  18. ll l,r;
  19. cin>>l>>r;
  20.  
  21. l--;
  22. r--;
  23.  
  24. string s1 = s.substr(l,r-l+1);
  25. string s2 = s1;
  26. reverse(s1.begin(),s1.end());
  27.  
  28. if(s1==s2){
  29. cout<<"YES"<<"\n";
  30. }else{
  31. cout<<"NO"<<"\n";
  32. }
  33.  
  34. }
  35.  
  36. return 0;
  37. }
Runtime error #stdin #stdout #stderr 0s 4384KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
terminate called after throwing an instance of 'std::out_of_range'
  what():  basic_string::substr: __pos (which is 47673814220583) > this->size() (which is 0)