-
Notifications
You must be signed in to change notification settings - Fork 0
/
10324 - Zeros and Ones.cpp
45 lines (41 loc) · 1.02 KB
/
10324 - Zeros and Ones.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
42
43
44
45
#include<string>
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main (void)
{
string zerosOnes;
int case_no = 0;
while(getline(cin, zerosOnes))
{
int queries;
scanf("%d", &queries);
printf("Case %d:\n", ++case_no);
while(queries--)
{
int a, b;
scanf("%d%d", &a, &b);
if(a == b) printf("Yes\n");
else
{
int x = min(a, b);
int y = max(a, b);
bool flag = true;
for(int i = x; i < y; i++)
{
if(zerosOnes[i] != zerosOnes[i+1])
{
flag = false;
break;
}
}
if(flag) printf("Yes\n");
else printf("No\n");
string hudai;
getline(cin, hudai);
}
}
}
return 0;
}