-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path10324.cpp
More file actions
33 lines (33 loc) · 795 Bytes
/
10324.cpp
File metadata and controls
33 lines (33 loc) · 795 Bytes
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
#include <bits/stdc++.h>
using namespace std;
char a[1000005];
int b[1000005];
int main() {
int i, j, k, n, t, l, T = 1;
while (gets(a)) {
l = strlen(a);
b[0] = 0;
b[1] = a[0] - '0';
for (i = 1; i < l; i++) {
b[i + 1] = b[i] + a[i] - '0';
}
scanf("%d", &n);
getchar();
printf("Case %d:\n", T++);
while (n--) {
scanf("%d %d", &k, &t);
getchar();
i = min(k, t);
j = max(k, t);
if (b[j + 1] - b[i] == 0) {
puts("Yes");
} else {
if ((b[j + 1] - b[i]) == (j - i + 1)) {
puts("Yes");
} else
puts("No");
}
}
}
return 0;
}