#include <iostream>
#include <vector>
using namespace std;
typedef vector <vector <bool>> matrix;
int n;
vector <string> rot;
/*
0 = intersect
1 = same
2 = parallel
*/
inline const matrix cm(vector <pair <int, int>> lamps = {}) {
matrix m(n, vector<bool>(n, false));
for (auto &p : lamps) m[p.first][p.second] = true;
return m;
}
short ask(short x1, short y1, short x2, short y2) {
cout << '?';
for (auto &i : cm({{x1, y1}, {x2, y2}})) {
cout << '\n';
for (bool &&j : i) cout << j;
}
cout << endl;
int x;
cin >> x;
if (x == 2 * n) return 2;
if (x == n) return 1;
return 0;
}
void answer(const matrix &m) {
cout << '!';
for (auto &i : m) {
cout << '\n';
for (bool &&j : i) cout << j;
}
exit(0);
}
char rotof(short x, short y) {
if (rot[x][y] == '.') {
for (int i = 0; i < n; i++) {
if (rot[x][i] != '.') {
if (ask(x, i, x, y)) return rot[x][y] = rot[x][i];
return rot[x][y] = rot[x][i] == 'V' ? 'H' : 'V';
}
if (rot[i][y] != '.') {
if (ask(i, y, x, y)) return rot[x][y] = rot[i][y];
return rot[x][y] = rot[i][y] == 'V' ? 'H' : 'V';
}
}
}
return rot[x][y];
}
void ansvert() {
matrix m = cm();
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
if (rot[j][i] == 'V') {
m[j][i] = true;
break;
}
}
}
answer(m);
}
void anshor() {
matrix m = cm();
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
if (rot[i][j] == 'H') {
m[i][j] = true;
break;
}
}
}
answer(m);
}
signed main() {
cin >> n;
rot = vector(n, string(n, '.'));
short ans = ask(0, 0, 0, 1);
if (ans == 2) rot[0][0] = rot[0][1] = 'V';
else if (ans == 1) rot[0][0] = rot[0][1] = 'H';
else {
ans = ask(0, 0, 0, 2);
if (ans == 2) {
rot[0][1] = 'H';
rot[0][0] = rot[0][2] = 'V';
}
else if (ans == 1) {
rot[0][1] = 'V';
rot[0][0] = rot[0][2] = 'H';
}
else if (ask(0, 1, 0, 2) == 2) {
rot[0][0] = 'H';
rot[0][1] = rot[0][2] = 'V';
}
else {
rot[0][0] = 'V';
rot[0][1] = rot[0][2] = 'H';
}
}
for (int i = 0, j = 0; i < n; i++) {
while (j < n && rotof(j, i) == 'H') j++;
if (j == n) anshor();
}
ansvert();
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
1 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 |
1 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 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
1 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 |
1 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 |
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 |
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 |
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 |
1 ms |
344 KB |
Output is correct |
42 |
Correct |
0 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 |
0 ms |
344 KB |
Output is correct |
46 |
Correct |
0 ms |
344 KB |
Output is correct |
47 |
Correct |
1 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 |
0 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 |
1 ms |
344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
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 |
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 |
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 |
1 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 |
356 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 |
1 ms |
344 KB |
Output is correct |
44 |
Correct |
0 ms |
344 KB |
Output is correct |
45 |
Correct |
0 ms |
380 KB |
Output is correct |
46 |
Correct |
0 ms |
344 KB |
Output is correct |
47 |
Correct |
0 ms |
596 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 |
0 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 |
Partially correct |
30 ms |
344 KB |
Partially correct |
60 |
Partially correct |
28 ms |
344 KB |
Partially correct |
61 |
Partially correct |
31 ms |
344 KB |
Partially correct |
62 |
Partially correct |
44 ms |
344 KB |
Partially correct |
63 |
Partially correct |
42 ms |
596 KB |
Partially correct |
64 |
Partially correct |
51 ms |
344 KB |
Partially correct |
65 |
Partially correct |
81 ms |
340 KB |
Partially correct |
66 |
Partially correct |
74 ms |
344 KB |
Partially correct |
67 |
Partially correct |
81 ms |
1172 KB |
Partially correct |
68 |
Partially correct |
51 ms |
344 KB |
Partially correct |
69 |
Partially correct |
37 ms |
344 KB |
Partially correct |
70 |
Partially correct |
39 ms |
344 KB |
Partially correct |
71 |
Partially correct |
33 ms |
344 KB |
Partially correct |
72 |
Partially correct |
39 ms |
344 KB |
Partially correct |
73 |
Partially correct |
38 ms |
340 KB |
Partially correct |
74 |
Partially correct |
57 ms |
344 KB |
Partially correct |
75 |
Partially correct |
29 ms |
592 KB |
Partially correct |
76 |
Partially correct |
34 ms |
344 KB |
Partially correct |
77 |
Partially correct |
45 ms |
344 KB |
Partially correct |
78 |
Partially correct |
43 ms |
344 KB |
Partially correct |
79 |
Partially correct |
35 ms |
344 KB |
Partially correct |
80 |
Partially correct |
45 ms |
344 KB |
Partially correct |
81 |
Partially correct |
69 ms |
340 KB |
Partially correct |
82 |
Partially correct |
69 ms |
344 KB |
Partially correct |
83 |
Partially correct |
70 ms |
460 KB |
Partially correct |
84 |
Partially correct |
46 ms |
432 KB |
Partially correct |
85 |
Partially correct |
63 ms |
520 KB |
Partially correct |
86 |
Partially correct |
58 ms |
344 KB |
Partially correct |
87 |
Partially correct |
59 ms |
344 KB |
Partially correct |
88 |
Partially correct |
29 ms |
344 KB |
Partially correct |
89 |
Partially correct |
29 ms |
456 KB |
Partially correct |
90 |
Partially correct |
43 ms |
344 KB |
Partially correct |
91 |
Partially correct |
52 ms |
344 KB |
Partially correct |
92 |
Partially correct |
56 ms |
344 KB |
Partially correct |
93 |
Partially correct |
45 ms |
344 KB |
Partially correct |
94 |
Partially correct |
58 ms |
344 KB |
Partially correct |
95 |
Partially correct |
30 ms |
344 KB |
Partially correct |
96 |
Partially correct |
66 ms |
344 KB |
Partially correct |
97 |
Correct |
0 ms |
344 KB |
Output is correct |