Plabon_dutta

Uva 10324

Mar 4th, 2021 (edited)
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.76 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<string.h>
  3. #include<math.h>
  4.  
  5. int main() {
  6.     char str[1000010];
  7.     int j=1;
  8.     while(scanf("%s", &str)!=EOF) {
  9.         if(strcmp(str,"\n")==0 || str[0]=='\0') break;
  10.         int n, a, b, i;
  11.         scanf("%d", &n);
  12.         printf("Case %d:\n", j++);
  13.         while(n--) {
  14.             scanf("%d %d", &a, &b);
  15.             if(b<a) {
  16.                 a+=b;
  17.                 b=a-b;
  18.                 a-=b;
  19.             }
  20.             char ch=str[a];
  21.             int c=0;
  22.             for(i=a; i<=b; i++) {
  23.                 if(str[i]!=ch) {
  24.                     c++;
  25.                     break;
  26.                 }
  27.             }
  28.             if(c==0) printf("Yes\n");
  29.             else printf("No\n");
  30.         }
  31.     }
  32.     return 0;
  33. }
  34.  
Add Comment
Please, Sign In to add comment