-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathuva-10324.cpp
More file actions
54 lines (40 loc) · 1.06 KB
/
uva-10324.cpp
File metadata and controls
54 lines (40 loc) · 1.06 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
#include <bits/stdc++.h>
#define MAX 1000000
using namespace std;
char number[MAX + 5];
int cumSum[MAX + 5];
int main()
{
freopen("in.txt", "r", stdin);
freopen("out.txt", "w", stdout);
int n, i, j, k, Len, sum, testCase = 1;
bool isSame;
while (scanf("%s", number) == 1) {
printf("Case %d:\n", testCase++);
Len = strlen(number);
cumSum[0] = number[0] - '0';
for (i = 1; i < Len; i++) {
cumSum[i] = cumSum[i - 1] + (number[i] - '0');
}
scanf("%d", &n);
for (k = 1; k <= n; k++) {
scanf("%d%d", &i, &j);
if (i > j) {
swap(i, j);
}
if (i != 0) {
sum = cumSum[j] - cumSum[i - 1];
}
else {
sum = cumSum[j];
}
if (sum == 0 || sum == j - i + 1) {
printf("Yes\n");
}
else {
printf("No\n");
}
}
}
return 0;
}