-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path4.cpp
More file actions
97 lines (85 loc) · 1.29 KB
/
4.cpp
File metadata and controls
97 lines (85 loc) · 1.29 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
// Works only first test set
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ar array
int b,a[100],sp,dp;
int qry(int i)
{
cout<<i+1<<endl;
int ans;
cin>>ans;
return ans;
}
void findpair(int i)
{
a[i]=qry(i);
a[b-1-i]=qry(b-1-i);
if(sp==-1&&a[i]==a[b-1-i])
{
sp=i;
}
if(dp==-1&&a[i]!=a[b-1-i])
{
dp=i;
}
}
void findchange()
{
bool comp=0;
if(sp!=-1&&a[sp]!=qry(sp))
comp=1;
bool rev=comp;
if(dp!=-1&&a[dp]!=qry(dp))
rev=!comp;
if(comp)
for(int i=0;i<b;++i)
a[i]=!a[i];
if(rev)
for(int i=0;i<b/2;++i)
swap(a[i],a[b-1-i]);
}
void solve()
{
sp=-1;
dp=-1;
//qry(0);
int c=0;
for(;c<5;++c)
{
findpair(c);
}
findchange();
while(c<b/2)
{
int i=0;
for(;i<4&&c<b/2;++i,++c)
{
findpair(c);
}
if(i==4)
{
findchange();
}
}
for(int i=0;i<b;++i)
{
cout<<a[i];
}
cout<<endl;
char ok;
cin>>ok;
if(ok=='N')
exit(0);
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
int t;
cin>>t>>b;
for(int i=1;i<=t;++i)
{
solve();
}
}