#include <bits/stdc++.h>
using namespace std;
#define ar array
#define int long long
#define ld long double
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
const int N = 200;
const int X = N * N;
const int K = 500;
const int MOD = 1e9 + 7;
const int LOG = 21;
const int INF = 1e17;
string ans[N];
int n;
int ask(int a, int b,int c,int d){
string s[n];
for(int i = 0;i < n;i++)s[i] = string(n, '0');
s[a][b] = '1';
s[c][d] = '1';
cout<<"?"<<endl;
for(int i = 0;i < n;i++)cout<<s[i]<<endl;
int x;
cin>>x;
return x;
}
void find(int x,int y){
if(ans[x][y] != '$')return;
for(int i = 0;i < n;i++){
if(ans[x][i] != '$'){
if(ask(x, i, x, y) == 2 * n - 1)ans[x][y] = (ans[x][i] == 'V' ? 'H' : 'V');
else ans[x][y] = ans[x][i];
return;
}
if(ans[i][y] != '$'){
if(ask(i, y, x, y) == 2 * n - 1)ans[x][y] = (ans[i][y] == 'V' ? 'H' : 'V');
else ans[x][y] = ans[i][y];
return;
}
}
}
bitset<N> res[N];
bool b;
void hor(){
if(b)return;
b = 1;
for(int i = 0;i < n;i++){
for(int j = 0;j < n;j++){
if(ans[i][j] == 'H'){
res[i][j] = 1;
break;
}
}
}
}
void vert(){
if(b)return;
b = 1;
for(int i = 0;i < n;i++){
for(int j = 0;j < n;j++){
if(ans[j][i] == 'V'){
res[j][i] = 1;
break;
}
}
}
}
signed main(){ios::sync_with_stdio(false);cin.tie(0);
cin>>n;
for(int i = 0;i < n;i++)ans[i] = string(n, '$');
int x = ask(0, 0, 0, 1);
if(x == 2 * n)ans[0][0] = ans[0][1] = 'V';
else if(x == n)ans[0][0] = ans[0][1] = 'H';
else{
x = ask(0, 0, 0, 2);
if(x == 2 * n)ans[0][0] = ans[0][2] = 'V', ans[0][1] = 'H';
else if(x == n)ans[0][0] = ans[0][2] = 'H', ans[0][1] = 'V';
else{
x = ask(0, 1, 0, 2);
if(x == 2 * n)ans[0][1] = ans[0][2] = 'V', ans[0][0] = 'H';
else if(x == n)ans[0][1] = ans[0][2] = 'H', ans[0][0] = 'V';
}
}
int j = 0;
for(int i = 0;i < n;i++){
find(i, j);
while(j < n && ans[i][j] == 'V')find(i, ++j);
if(j == n)vert();
}
hor();
cout<<"!"<<endl;
for(int i = 0;i < n;i++){
for(int j = 0;j < n;j++){
cout<<res[i][j];
}
cout<<'\n';
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
504 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
0 ms |
344 KB |
Output is correct |
6 |
Correct |
0 ms |
344 KB |
Output is correct |
7 |
Correct |
0 ms |
344 KB |
Output is correct |
8 |
Correct |
0 ms |
344 KB |
Output is correct |
9 |
Correct |
0 ms |
344 KB |
Output is correct |
10 |
Correct |
0 ms |
344 KB |
Output is correct |
11 |
Correct |
0 ms |
344 KB |
Output is correct |
12 |
Correct |
0 ms |
344 KB |
Output is correct |
13 |
Correct |
0 ms |
344 KB |
Output is correct |
14 |
Correct |
0 ms |
344 KB |
Output is correct |
15 |
Correct |
0 ms |
344 KB |
Output is correct |
16 |
Correct |
0 ms |
344 KB |
Output is correct |
17 |
Correct |
0 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
0 ms |
344 KB |
Output is correct |
6 |
Correct |
0 ms |
344 KB |
Output is correct |
7 |
Correct |
0 ms |
344 KB |
Output is correct |
8 |
Correct |
0 ms |
344 KB |
Output is correct |
9 |
Correct |
0 ms |
344 KB |
Output is correct |
10 |
Correct |
0 ms |
344 KB |
Output is correct |
11 |
Correct |
0 ms |
344 KB |
Output is correct |
12 |
Correct |
0 ms |
344 KB |
Output is correct |
13 |
Correct |
1 ms |
344 KB |
Output is correct |
14 |
Correct |
0 ms |
344 KB |
Output is correct |
15 |
Correct |
0 ms |
344 KB |
Output is correct |
16 |
Correct |
0 ms |
344 KB |
Output is correct |
17 |
Correct |
0 ms |
344 KB |
Output is correct |
18 |
Correct |
1 ms |
344 KB |
Output is correct |
19 |
Correct |
1 ms |
344 KB |
Output is correct |
20 |
Correct |
0 ms |
344 KB |
Output is correct |
21 |
Correct |
0 ms |
344 KB |
Output is correct |
22 |
Correct |
0 ms |
344 KB |
Output is correct |
23 |
Correct |
0 ms |
344 KB |
Output is correct |
24 |
Correct |
0 ms |
344 KB |
Output is correct |
25 |
Correct |
0 ms |
344 KB |
Output is correct |
26 |
Correct |
0 ms |
344 KB |
Output is correct |
27 |
Correct |
0 ms |
344 KB |
Output is correct |
28 |
Correct |
0 ms |
344 KB |
Output is correct |
29 |
Correct |
1 ms |
344 KB |
Output is correct |
30 |
Correct |
0 ms |
344 KB |
Output is correct |
31 |
Correct |
0 ms |
344 KB |
Output is correct |
32 |
Correct |
0 ms |
344 KB |
Output is correct |
33 |
Correct |
0 ms |
344 KB |
Output is correct |
34 |
Correct |
0 ms |
344 KB |
Output is correct |
35 |
Correct |
0 ms |
344 KB |
Output is correct |
36 |
Correct |
1 ms |
344 KB |
Output is correct |
37 |
Correct |
0 ms |
344 KB |
Output is correct |
38 |
Correct |
0 ms |
344 KB |
Output is correct |
39 |
Correct |
0 ms |
344 KB |
Output is correct |
40 |
Correct |
0 ms |
344 KB |
Output is correct |
41 |
Correct |
0 ms |
344 KB |
Output is correct |
42 |
Correct |
1 ms |
344 KB |
Output is correct |
43 |
Correct |
0 ms |
344 KB |
Output is correct |
44 |
Correct |
0 ms |
344 KB |
Output is correct |
45 |
Correct |
1 ms |
344 KB |
Output is correct |
46 |
Correct |
0 ms |
344 KB |
Output is correct |
47 |
Correct |
0 ms |
344 KB |
Output is correct |
48 |
Correct |
1 ms |
344 KB |
Output is correct |
49 |
Correct |
0 ms |
344 KB |
Output is correct |
50 |
Correct |
0 ms |
344 KB |
Output is correct |
51 |
Correct |
1 ms |
344 KB |
Output is correct |
52 |
Correct |
0 ms |
344 KB |
Output is correct |
53 |
Correct |
0 ms |
344 KB |
Output is correct |
54 |
Correct |
0 ms |
344 KB |
Output is correct |
55 |
Correct |
0 ms |
344 KB |
Output is correct |
56 |
Correct |
0 ms |
344 KB |
Output is correct |
57 |
Correct |
0 ms |
344 KB |
Output is correct |
58 |
Correct |
0 ms |
344 KB |
Output is correct |
59 |
Correct |
0 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
0 ms |
344 KB |
Output is correct |
6 |
Correct |
0 ms |
344 KB |
Output is correct |
7 |
Correct |
0 ms |
344 KB |
Output is correct |
8 |
Correct |
0 ms |
344 KB |
Output is correct |
9 |
Correct |
0 ms |
344 KB |
Output is correct |
10 |
Correct |
0 ms |
344 KB |
Output is correct |
11 |
Correct |
1 ms |
344 KB |
Output is correct |
12 |
Correct |
0 ms |
344 KB |
Output is correct |
13 |
Correct |
0 ms |
344 KB |
Output is correct |
14 |
Correct |
0 ms |
344 KB |
Output is correct |
15 |
Correct |
0 ms |
344 KB |
Output is correct |
16 |
Correct |
0 ms |
344 KB |
Output is correct |
17 |
Correct |
0 ms |
344 KB |
Output is correct |
18 |
Correct |
0 ms |
344 KB |
Output is correct |
19 |
Correct |
0 ms |
344 KB |
Output is correct |
20 |
Correct |
0 ms |
344 KB |
Output is correct |
21 |
Correct |
1 ms |
344 KB |
Output is correct |
22 |
Correct |
0 ms |
344 KB |
Output is correct |
23 |
Correct |
0 ms |
344 KB |
Output is correct |
24 |
Correct |
0 ms |
344 KB |
Output is correct |
25 |
Correct |
0 ms |
344 KB |
Output is correct |
26 |
Correct |
0 ms |
344 KB |
Output is correct |
27 |
Correct |
0 ms |
344 KB |
Output is correct |
28 |
Correct |
0 ms |
344 KB |
Output is correct |
29 |
Correct |
0 ms |
344 KB |
Output is correct |
30 |
Correct |
0 ms |
344 KB |
Output is correct |
31 |
Correct |
0 ms |
344 KB |
Output is correct |
32 |
Correct |
0 ms |
344 KB |
Output is correct |
33 |
Correct |
0 ms |
344 KB |
Output is correct |
34 |
Correct |
0 ms |
344 KB |
Output is correct |
35 |
Correct |
0 ms |
344 KB |
Output is correct |
36 |
Correct |
0 ms |
344 KB |
Output is correct |
37 |
Correct |
0 ms |
344 KB |
Output is correct |
38 |
Correct |
1 ms |
344 KB |
Output is correct |
39 |
Correct |
0 ms |
344 KB |
Output is correct |
40 |
Correct |
0 ms |
340 KB |
Output is correct |
41 |
Correct |
1 ms |
344 KB |
Output is correct |
42 |
Correct |
1 ms |
344 KB |
Output is correct |
43 |
Correct |
0 ms |
344 KB |
Output is correct |
44 |
Correct |
0 ms |
384 KB |
Output is correct |
45 |
Correct |
0 ms |
344 KB |
Output is correct |
46 |
Correct |
0 ms |
344 KB |
Output is correct |
47 |
Correct |
0 ms |
344 KB |
Output is correct |
48 |
Correct |
0 ms |
344 KB |
Output is correct |
49 |
Correct |
0 ms |
344 KB |
Output is correct |
50 |
Correct |
0 ms |
344 KB |
Output is correct |
51 |
Correct |
0 ms |
344 KB |
Output is correct |
52 |
Correct |
0 ms |
344 KB |
Output is correct |
53 |
Correct |
1 ms |
344 KB |
Output is correct |
54 |
Correct |
0 ms |
344 KB |
Output is correct |
55 |
Correct |
0 ms |
344 KB |
Output is correct |
56 |
Correct |
0 ms |
344 KB |
Output is correct |
57 |
Correct |
0 ms |
344 KB |
Output is correct |
58 |
Correct |
0 ms |
344 KB |
Output is correct |
59 |
Partially correct |
3 ms |
488 KB |
Partially correct |
60 |
Partially correct |
3 ms |
536 KB |
Partially correct |
61 |
Partially correct |
4 ms |
488 KB |
Partially correct |
62 |
Partially correct |
4 ms |
484 KB |
Partially correct |
63 |
Partially correct |
4 ms |
484 KB |
Partially correct |
64 |
Partially correct |
4 ms |
488 KB |
Partially correct |
65 |
Partially correct |
6 ms |
480 KB |
Partially correct |
66 |
Partially correct |
8 ms |
784 KB |
Partially correct |
67 |
Partially correct |
6 ms |
484 KB |
Partially correct |
68 |
Partially correct |
7 ms |
488 KB |
Partially correct |
69 |
Partially correct |
4 ms |
488 KB |
Partially correct |
70 |
Partially correct |
4 ms |
484 KB |
Partially correct |
71 |
Partially correct |
4 ms |
716 KB |
Partially correct |
72 |
Partially correct |
3 ms |
480 KB |
Partially correct |
73 |
Partially correct |
4 ms |
480 KB |
Partially correct |
74 |
Partially correct |
5 ms |
480 KB |
Partially correct |
75 |
Partially correct |
3 ms |
480 KB |
Partially correct |
76 |
Partially correct |
4 ms |
480 KB |
Partially correct |
77 |
Partially correct |
5 ms |
484 KB |
Partially correct |
78 |
Partially correct |
4 ms |
480 KB |
Partially correct |
79 |
Partially correct |
4 ms |
484 KB |
Partially correct |
80 |
Partially correct |
6 ms |
1428 KB |
Partially correct |
81 |
Partially correct |
7 ms |
484 KB |
Partially correct |
82 |
Partially correct |
8 ms |
592 KB |
Partially correct |
83 |
Partially correct |
6 ms |
484 KB |
Partially correct |
84 |
Partially correct |
5 ms |
484 KB |
Partially correct |
85 |
Partially correct |
8 ms |
484 KB |
Partially correct |
86 |
Partially correct |
6 ms |
620 KB |
Partially correct |
87 |
Partially correct |
6 ms |
484 KB |
Partially correct |
88 |
Partially correct |
5 ms |
480 KB |
Partially correct |
89 |
Partially correct |
5 ms |
484 KB |
Partially correct |
90 |
Partially correct |
4 ms |
484 KB |
Partially correct |
91 |
Partially correct |
6 ms |
480 KB |
Partially correct |
92 |
Partially correct |
6 ms |
584 KB |
Partially correct |
93 |
Partially correct |
7 ms |
480 KB |
Partially correct |
94 |
Partially correct |
7 ms |
480 KB |
Partially correct |
95 |
Partially correct |
3 ms |
480 KB |
Partially correct |
96 |
Partially correct |
5 ms |
484 KB |
Partially correct |
97 |
Correct |
1 ms |
344 KB |
Output is correct |