#include #include #include #include #include #include int answerQuery(char* s, int l, int r) { // Return the answer for this query modulo 1000000007. int alpha[26],i={0}; for(i=l-1;i1) break; } if(flag>1) { } }*/ if(l==r) { return 1; } else if(r==l+1) { if(s[l-1]==s[l]) return 1; else return 1; } else if(r==l+2) { return 1; } return 0; } int main() { char* s = (char *)malloc(512000 * sizeof(char)); scanf("%s", s); int q; scanf("%i", &q); for(int a0 = 0; a0 < q; a0++){ int l; int r; scanf("%i %i", &l, &r); int result = answerQuery(s, l, r); printf("%d\n", result); } return 0; }