fork(3) download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. int main(){
  4. int n,i,j,q[1000000];
  5. char t1,t2,p[1000001];
  6. scanf("%s",p);
  7. q[0]=0;
  8. for(i=0,j=1;p[j];j++){
  9. if(p[i]!=p[j]) i=j;
  10. q[j]=j-i;
  11. }
  12. scanf("%d",&n);
  13. while(n--){
  14. scanf("%d%d",&i,&j);
  15. if(q[(i>j)?i:j]>=abs(i-j)) printf("Yes\n");
  16. else printf("No\n");
  17. }
  18. return 0;
  19. }
Success #stdin #stdout 0s 7056KB
stdin
0000011111
3
0 5
4 2
5 9
stdout
No
Yes
Yes