#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define debug(...) // ignore
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef long double ld;
int main() {
int n;
cin >> n;
auto printgrid = [&](vector<pii> v) {
vector<string> grid(n,string(n,'0'));
for(auto [a,b] : v) grid[a][b] = '1';
for(auto g : grid) cout << g << endl;
};
auto query = [&](vector<pii> v) {
cout << "?" << ' ';
printgrid(v);
int x;
cin >> x;
return x;
};
auto answer = [&](vector<pii> v) {
assert(sz(v) == n);
cout << "!" << ' ';
printgrid(v);
exit(0);
};
vector<pii> ans;
rep(i,0,n) {
vector<pii> q;
rep(j,0,n) q.emplace_back(i,j);
int k = query(q);
if(k == n*n) answer(q);
if(k == n) q = {q[0]};
while(sz(q) >= 3) {
vector<pii> a, b;
for(auto p : q) {
swap(a,b);
a.emplace_back(p);
}
assert(sz(a) >= 2);
int k = query(a);
if(k == n) { q = {a[0]}; break; }
if(k < sz(a)*n) q = a;
else q = b;
}
if(sz(q) == 2) {
if(sz(ans)) {
if(query({ans[0],q[0]}) == 2*n) q = {q[0]};
else q = {q[1]};
}
else {
pii t = {i,0};
while(t == q[0] || t == q[1]) ++t.second;
int k0 = query({q[0],t});
if(k0 == 2*n) q = {q[1]};
else if(k0 == n) q = {q[0]};
else {
int k1 = query({q[1],t});
if(k1 == 2*n) q = {q[0]};
else q = {q[1]};
}
}
}
assert(sz(q) == 1);
ans.emplace_back(q.back());
}
answer(ans);
}
# |
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 |
1 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 |
1 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 |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
1 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 |
1 ms |
340 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 |
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 |
0 ms |
348 KB |
Output is correct |
22 |
Correct |
0 ms |
344 KB |
Output is correct |
23 |
Correct |
1 ms |
344 KB |
Output is correct |
24 |
Correct |
0 ms |
344 KB |
Output is correct |
25 |
Correct |
0 ms |
352 KB |
Output is correct |
26 |
Correct |
1 ms |
356 KB |
Output is correct |
27 |
Correct |
1 ms |
348 KB |
Output is correct |
28 |
Correct |
1 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 |
1 ms |
344 KB |
Output is correct |
35 |
Correct |
1 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 |
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 |
596 KB |
Output is correct |
43 |
Correct |
1 ms |
344 KB |
Output is correct |
44 |
Correct |
0 ms |
344 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 |
1 ms |
344 KB |
Output is correct |
49 |
Correct |
0 ms |
344 KB |
Output is correct |
50 |
Correct |
1 ms |
344 KB |
Output is correct |
51 |
Correct |
0 ms |
344 KB |
Output is correct |
52 |
Correct |
1 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 |
1 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 |
1 ms |
344 KB |
Output is correct |
59 |
Correct |
0 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 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 |
416 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 |
1 ms |
344 KB |
Output is correct |
14 |
Correct |
0 ms |
344 KB |
Output is correct |
15 |
Correct |
1 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 |
1 ms |
344 KB |
Output is correct |
21 |
Correct |
0 ms |
344 KB |
Output is correct |
22 |
Correct |
1 ms |
344 KB |
Output is correct |
23 |
Correct |
0 ms |
344 KB |
Output is correct |
24 |
Correct |
1 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 |
1 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 |
1 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 |
1 ms |
344 KB |
Output is correct |
41 |
Correct |
0 ms |
356 KB |
Output is correct |
42 |
Correct |
1 ms |
344 KB |
Output is correct |
43 |
Correct |
1 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 |
1 ms |
344 KB |
Output is correct |
58 |
Correct |
0 ms |
344 KB |
Output is correct |
59 |
Partially correct |
5 ms |
456 KB |
Partially correct |
60 |
Correct |
0 ms |
344 KB |
Output is correct |
61 |
Partially correct |
24 ms |
464 KB |
Partially correct |
62 |
Partially correct |
21 ms |
684 KB |
Partially correct |
63 |
Partially correct |
25 ms |
704 KB |
Partially correct |
64 |
Partially correct |
40 ms |
660 KB |
Partially correct |
65 |
Partially correct |
29 ms |
676 KB |
Partially correct |
66 |
Partially correct |
34 ms |
448 KB |
Partially correct |
67 |
Partially correct |
26 ms |
456 KB |
Partially correct |
68 |
Partially correct |
26 ms |
720 KB |
Partially correct |
69 |
Partially correct |
41 ms |
452 KB |
Partially correct |
70 |
Partially correct |
24 ms |
456 KB |
Partially correct |
71 |
Partially correct |
24 ms |
456 KB |
Partially correct |
72 |
Correct |
0 ms |
344 KB |
Output is correct |
73 |
Correct |
2 ms |
676 KB |
Output is correct |
74 |
Correct |
2 ms |
456 KB |
Output is correct |
75 |
Partially correct |
30 ms |
936 KB |
Partially correct |
76 |
Partially correct |
44 ms |
452 KB |
Partially correct |
77 |
Partially correct |
23 ms |
456 KB |
Partially correct |
78 |
Partially correct |
7 ms |
452 KB |
Partially correct |
79 |
Partially correct |
25 ms |
456 KB |
Partially correct |
80 |
Partially correct |
5 ms |
456 KB |
Partially correct |
81 |
Partially correct |
8 ms |
676 KB |
Partially correct |
82 |
Partially correct |
10 ms |
460 KB |
Partially correct |
83 |
Partially correct |
13 ms |
460 KB |
Partially correct |
84 |
Partially correct |
36 ms |
536 KB |
Partially correct |
85 |
Partially correct |
36 ms |
836 KB |
Partially correct |
86 |
Partially correct |
14 ms |
708 KB |
Partially correct |
87 |
Partially correct |
36 ms |
1060 KB |
Partially correct |
88 |
Partially correct |
13 ms |
748 KB |
Partially correct |
89 |
Partially correct |
32 ms |
608 KB |
Partially correct |
90 |
Partially correct |
22 ms |
660 KB |
Partially correct |
91 |
Partially correct |
15 ms |
592 KB |
Partially correct |
92 |
Partially correct |
31 ms |
688 KB |
Partially correct |
93 |
Partially correct |
27 ms |
684 KB |
Partially correct |
94 |
Partially correct |
31 ms |
924 KB |
Partially correct |
95 |
Partially correct |
33 ms |
912 KB |
Partially correct |
96 |
Partially correct |
35 ms |
676 KB |
Partially correct |
97 |
Correct |
0 ms |
344 KB |
Output is correct |