-
Notifications
You must be signed in to change notification settings - Fork 0
/
10324.cpp
41 lines (29 loc) · 794 Bytes
/
10324.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
#include <iostream>
#include <stdio.h>
#include <string.h>
using namespace std;
int main(int argc, char const *argv[])
{
int list[1000005], count, index, min, max, cases;
char sequence[1000005];
cases = 1;
while (scanf("%s", sequence) == 1) {
count = strlen(sequence);
index = 0;
list[0] = index;
for (int i = 1; i < count; ++i) {
if (sequence[i - 1] != sequence[i]) index++;
list[i] = index;
}
scanf("%d", &count);
printf("Case %d:\n", cases++);
for (int i = 0; i < count; ++i) {
scanf("%d %d", &min, &max);
if (list[min] == list[max])
printf("Yes\n");
else
printf("No\n");
}
}
return 0;
}