# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1048380 |
2024-08-08T07:10:55 Z |
정민찬(#11037) |
Light Bulbs (EGOI24_lightbulbs) |
C++17 |
|
225 ms |
1500 KB |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
int N;
vector<vector<int>> qry;
void init() {
for (int i=0; i<N; i++) {
for (int j=0; j<N; j++) {
qry[i][j] = 0;
}
}
}
int ask() {
cout << "?\n";
for (int i=0; i<N; i++) {
for (int j=0; j<N; j++) {
cout << qry[i][j];
}
cout << '\n';
}
cout.flush();
int ret;
cin >> ret;
return ret;
}
void answer(vector<vector<int>> &ans) {
cout << "!\n";
for (int i=0; i<N; i++) {
for (int j=0; j<N; j++) {
cout << ans[i][j];
}
cout << '\n';
}
cout.flush();
exit(0);
}
int dnc(int s, int e, int row) {
if (s == e) {
int oth = (s == 0 ? N-1 : 0);
init();
qry[row][s] = 1;
qry[row][oth] = 1;
int ret = ask();
if (ret == 2*N) return -1;
return s;
}
if (s + 1 == e) {
int oth;
for (int i=0; i<3; i++) {
if (i != s && i != e) {
oth = i;
break;
}
}
init();
qry[row][s] = 1;
qry[row][oth] = 1;
int ret1 = ask();
init();
qry[row][e] = 1;
qry[row][oth] = 1;
int ret2 = ask();
if (ret1 < ret2) return s;
if (ret1 > ret2) return e;
if (ret1 == 2 * N) return -1;
return s;
}
int mid = s + e >> 1;
init();
for (int i=s; i<=mid; i++) {
qry[row][i] = 1;
}
int ret = ask();
if (ret == (mid-s+1) * N) {
return dnc(mid+1, e, row);
}
return dnc(s, mid, row);
}
int main() {
ios_base :: sync_with_stdio(false); cin.tie(NULL);
cin >> N;
vector<vector<int>> ans(N, vector<int>(N, 0));
qry.resize(N, vector<int>(N, 0));
for (int i=0; i<N; i++) {
int pos = dnc(0, N-1, i);
if (pos == -1) {
for (int j=0; j<N; j++) {
for (int k=0; k<N; k++) {
ans[j][k] = 0;
}
}
for (int j=0; j<N; j++) {
ans[i][j] = 1;
}
answer(ans);
}
ans[i][pos] = 1;
}
answer(ans);
}
Compilation message
Main.cpp: In function 'int dnc(int, int, int)':
Main.cpp:76:17: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
76 | int mid = s + e >> 1;
| ~~^~~
Main.cpp:65:21: warning: 'oth' may be used uninitialized in this function [-Wmaybe-uninitialized]
65 | qry[row][oth] = 1;
| ^
# |
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 |
352 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 |
1 ms |
344 KB |
Output is correct |
16 |
Correct |
1 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 |
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 |
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 |
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 |
1 ms |
344 KB |
Output is correct |
26 |
Correct |
0 ms |
344 KB |
Output is correct |
27 |
Correct |
1 ms |
344 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 |
1 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 |
1 ms |
344 KB |
Output is correct |
40 |
Correct |
1 ms |
344 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 |
1 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 |
0 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 |
1 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 |
1 ms |
344 KB |
Output is correct |
55 |
Correct |
0 ms |
344 KB |
Output is correct |
56 |
Correct |
1 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 |
356 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 |
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 |
1 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 |
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 |
1 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 |
1 ms |
344 KB |
Output is correct |
26 |
Correct |
1 ms |
344 KB |
Output is correct |
27 |
Correct |
1 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 |
1 ms |
344 KB |
Output is correct |
32 |
Correct |
0 ms |
344 KB |
Output is correct |
33 |
Correct |
1 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 |
1 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 |
1 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 |
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 |
1 ms |
344 KB |
Output is correct |
55 |
Correct |
1 ms |
344 KB |
Output is correct |
56 |
Correct |
1 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 |
181 ms |
544 KB |
Partially correct |
60 |
Correct |
2 ms |
344 KB |
Output is correct |
61 |
Partially correct |
188 ms |
764 KB |
Partially correct |
62 |
Partially correct |
207 ms |
540 KB |
Partially correct |
63 |
Partially correct |
181 ms |
616 KB |
Partially correct |
64 |
Partially correct |
182 ms |
540 KB |
Partially correct |
65 |
Partially correct |
209 ms |
620 KB |
Partially correct |
66 |
Partially correct |
199 ms |
540 KB |
Partially correct |
67 |
Partially correct |
189 ms |
696 KB |
Partially correct |
68 |
Partially correct |
200 ms |
1500 KB |
Partially correct |
69 |
Partially correct |
194 ms |
552 KB |
Partially correct |
70 |
Partially correct |
225 ms |
544 KB |
Partially correct |
71 |
Partially correct |
199 ms |
1204 KB |
Partially correct |
72 |
Correct |
2 ms |
344 KB |
Output is correct |
73 |
Partially correct |
75 ms |
544 KB |
Partially correct |
74 |
Partially correct |
125 ms |
548 KB |
Partially correct |
75 |
Partially correct |
207 ms |
956 KB |
Partially correct |
76 |
Partially correct |
203 ms |
768 KB |
Partially correct |
77 |
Partially correct |
176 ms |
540 KB |
Partially correct |
78 |
Partially correct |
55 ms |
544 KB |
Partially correct |
79 |
Partially correct |
205 ms |
1208 KB |
Partially correct |
80 |
Partially correct |
202 ms |
544 KB |
Partially correct |
81 |
Partially correct |
191 ms |
728 KB |
Partially correct |
82 |
Partially correct |
205 ms |
1224 KB |
Partially correct |
83 |
Partially correct |
197 ms |
732 KB |
Partially correct |
84 |
Partially correct |
190 ms |
688 KB |
Partially correct |
85 |
Partially correct |
201 ms |
656 KB |
Partially correct |
86 |
Partially correct |
195 ms |
636 KB |
Partially correct |
87 |
Partially correct |
199 ms |
728 KB |
Partially correct |
88 |
Partially correct |
202 ms |
764 KB |
Partially correct |
89 |
Partially correct |
181 ms |
536 KB |
Partially correct |
90 |
Partially correct |
214 ms |
548 KB |
Partially correct |
91 |
Partially correct |
205 ms |
1220 KB |
Partially correct |
92 |
Partially correct |
213 ms |
544 KB |
Partially correct |
93 |
Partially correct |
223 ms |
540 KB |
Partially correct |
94 |
Partially correct |
201 ms |
1488 KB |
Partially correct |
95 |
Partially correct |
193 ms |
544 KB |
Partially correct |
96 |
Partially correct |
215 ms |
544 KB |
Partially correct |
97 |
Correct |
0 ms |
344 KB |
Output is correct |