-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathARC070F_HonestOrUnkind.cpp
More file actions
48 lines (43 loc) · 979 Bytes
/
ARC070F_HonestOrUnkind.cpp
File metadata and controls
48 lines (43 loc) · 979 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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include<bits/stdc++.h>
#define ll long long
#define uint unsigned int
#define ull unsigned long long
using namespace std;
int qrd(){int a=0,b=1,c=getchar();while(c>'9'||c<'0'){if(c=='-')b=-1;c=getchar();}while(c>='0'&&c<='9')a=a*10+c-48,c=getchar();return a*b;}
int a,b;
int ans[4003];
stack<int> Stack;
bool query(int x, int y)
{
printf("? %d %d\n", x, y);
fflush(stdout);
char s[3]; scanf("%s", s);
return s[0] == 'Y';
}
void Solve()
{
a=qrd();b=qrd();
if (a<=b)
{
puts("Impossible");
return;
}
for(int i=0;i<a+b;i++)
{
if (Stack.empty()) Stack.push(i);
else
{
if (query(Stack.top(), i)) Stack.push(i);
else Stack.pop();
}
}
for(int i = 0; i < a + b; ++i) if (query(Stack.top(), i)) ans[i] = 1;
printf("! ");
for(int i = 0; i < a + b; ++i) printf("%d", ans[i]);
}
int main()
{
int T=1;//qrd();
while(T--) Solve();
return 0;
}