# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1048365 |
2024-08-08T07:05:39 Z |
이온조(#11092) |
Light Bulbs (EGOI24_lightbulbs) |
C++17 |
|
220 ms |
1032 KB |
#include <bits/stdc++.h>
using namespace std;
int N, A[111][111];
int query(vector<int> V, bool ans) {
memset(A, 0, sizeof(A));
for(auto it: V) A[it / N][it % N] = 1;
if(!ans) puts("?");
else puts("!");
for(int i=0; i<N; i++) {
for(int j=0; j<N; j++) printf("%d", A[i][j]);
puts("");
}
fflush(stdout);
if(ans) exit(0);
int ret; scanf("%d", &ret);
return ret;
}
int D[111], P[111];
int main() {
scanf("%d", &N);
int a = query({0, 1}, 0), b = query({1, 2}, 0), c = query({0, 2}, 0);
if(a == 2*N || c == 2*N || (a == 2*N - 1 && c == 2*N - 1 && b == N)) D[0] = 1;
for(int i=1; i<N; i++) {
if(query({0, N*i + i}, 0) == 2*N) D[i] = D[0];
else D[i] = D[0] ^ 1;
}
int cnt = 0;
for(int i=0; i<N; i++) if(D[i]) ++cnt;
if(cnt > N - cnt) {
for(int i=0; i<N; i++) if(D[i]) P[i] = i*N + i;
for(int i=0; i<N; i++) if(!D[i]) {
vector<int> V;
for(int j=0; j<N; j++) V.push_back(j*N + i);
int l;
while(V.size() > 2) {
vector<int> L, R;
for(int i=0; i<(V.size()+1)/2; i++) L.push_back(V[i]);
for(int i=(V.size()+1)/2; i<V.size(); i++) R.push_back(V[i]);
if(l = query(L, 0) < N * L.size()) V = L;
else V = R;
}
bool ok = 0;
for(auto it: V) if(D[0] ^ (query({0, it}, 0) == 2*N - 1)) P[i] = it, ok = 1;
if(!ok) {
vector<int> S;
for(int j=0; j<N; j++) S.push_back(j*N + i);
query(S, 1);
}
}
vector<int> S;
for(int i=0; i<N; i++) S.push_back(P[i]);
query(S, 1);
}
else {
for(int i=0; i<N; i++) if(!D[i]) P[i] = i*N + i;
for(int i=0; i<N; i++) if(D[i]) {
vector<int> V;
for(int j=0; j<N; j++) V.push_back(i*N + j);
int l;
while(V.size() > 2) {
vector<int> L, R;
for(int i=0; i<(V.size()+1)/2; i++) L.push_back(V[i]);
for(int i=(V.size()+1)/2; i<V.size(); i++) R.push_back(V[i]);
if(l = query(L, 0) < N * L.size()) V = L;
else V = R;
}
bool ok = 0;
for(auto it: V) if((D[0] ^ (query({0, it}, 0) == 2*N - 1)) == 0) P[i] = it, ok = 1;
if(!ok) {
vector<int> S;
for(int j=0; j<N; j++) S.push_back(i*N + j);
query(S, 1);
}
}
vector<int> S;
for(int i=0; i<N; i++) S.push_back(P[i]);
query(S, 1);
}
return 0;
}
Compilation message
Main.cpp: In function 'int main()':
Main.cpp:41:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
41 | for(int i=0; i<(V.size()+1)/2; i++) L.push_back(V[i]);
| ~^~~~~~~~~~~~~~~
Main.cpp:42:32: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
42 | for(int i=(V.size()+1)/2; i<V.size(); i++) R.push_back(V[i]);
| ~^~~~~~~~~
Main.cpp:43:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
43 | if(l = query(L, 0) < N * L.size()) V = L;
| ~~~~~~~~~~~~^~~~~~~~~~~~~~
Main.cpp:43:10: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
43 | if(l = query(L, 0) < N * L.size()) V = L;
| ~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:66:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
66 | for(int i=0; i<(V.size()+1)/2; i++) L.push_back(V[i]);
| ~^~~~~~~~~~~~~~~
Main.cpp:67:32: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
67 | for(int i=(V.size()+1)/2; i<V.size(); i++) R.push_back(V[i]);
| ~^~~~~~~~~
Main.cpp:68:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
68 | if(l = query(L, 0) < N * L.size()) V = L;
| ~~~~~~~~~~~~^~~~~~~~~~~~~~
Main.cpp:68:10: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
68 | if(l = query(L, 0) < N * L.size()) V = L;
| ~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp: In function 'int query(std::vector<int>, bool)':
Main.cpp:17:16: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
17 | int ret; scanf("%d", &ret);
| ~~~~~^~~~~~~~~~~~
Main.cpp: In function 'int main()':
Main.cpp:24:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
24 | scanf("%d", &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 |
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 |
# |
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 |
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 |
1 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 |
1 ms |
344 KB |
Output is correct |
18 |
Correct |
0 ms |
344 KB |
Output is correct |
19 |
Correct |
1 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 |
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 |
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 |
1 ms |
344 KB |
Output is correct |
34 |
Correct |
0 ms |
400 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 |
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 |
0 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 |
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 |
1 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 |
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 |
1 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 |
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 |
1 ms |
344 KB |
Output is correct |
7 |
Correct |
1 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 |
1 ms |
344 KB |
Output is correct |
19 |
Correct |
1 ms |
596 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 |
0 ms |
344 KB |
Output is correct |
24 |
Correct |
0 ms |
428 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 |
1 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 |
1 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 |
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 |
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 |
1 ms |
344 KB |
Output is correct |
55 |
Correct |
0 ms |
344 KB |
Output is correct |
56 |
Correct |
0 ms |
368 KB |
Output is correct |
57 |
Correct |
0 ms |
344 KB |
Output is correct |
58 |
Correct |
1 ms |
344 KB |
Output is correct |
59 |
Partially correct |
39 ms |
344 KB |
Partially correct |
60 |
Partially correct |
39 ms |
340 KB |
Partially correct |
61 |
Partially correct |
75 ms |
344 KB |
Partially correct |
62 |
Partially correct |
107 ms |
344 KB |
Partially correct |
63 |
Partially correct |
153 ms |
456 KB |
Partially correct |
64 |
Partially correct |
215 ms |
344 KB |
Partially correct |
65 |
Partially correct |
216 ms |
720 KB |
Partially correct |
66 |
Partially correct |
180 ms |
344 KB |
Partially correct |
67 |
Partially correct |
220 ms |
472 KB |
Partially correct |
68 |
Partially correct |
166 ms |
460 KB |
Partially correct |
69 |
Partially correct |
123 ms |
344 KB |
Partially correct |
70 |
Partially correct |
127 ms |
460 KB |
Partially correct |
71 |
Partially correct |
103 ms |
344 KB |
Partially correct |
72 |
Partially correct |
48 ms |
344 KB |
Partially correct |
73 |
Partially correct |
46 ms |
344 KB |
Partially correct |
74 |
Partially correct |
42 ms |
344 KB |
Partially correct |
75 |
Partially correct |
43 ms |
344 KB |
Partially correct |
76 |
Partially correct |
43 ms |
344 KB |
Partially correct |
77 |
Partially correct |
43 ms |
344 KB |
Partially correct |
78 |
Partially correct |
55 ms |
344 KB |
Partially correct |
79 |
Partially correct |
57 ms |
344 KB |
Partially correct |
80 |
Partially correct |
43 ms |
344 KB |
Partially correct |
81 |
Partially correct |
39 ms |
344 KB |
Partially correct |
82 |
Partially correct |
53 ms |
600 KB |
Partially correct |
83 |
Partially correct |
40 ms |
344 KB |
Partially correct |
84 |
Partially correct |
183 ms |
344 KB |
Partially correct |
85 |
Partially correct |
43 ms |
344 KB |
Partially correct |
86 |
Partially correct |
41 ms |
344 KB |
Partially correct |
87 |
Partially correct |
40 ms |
344 KB |
Partially correct |
88 |
Partially correct |
45 ms |
1032 KB |
Partially correct |
89 |
Partially correct |
41 ms |
344 KB |
Partially correct |
90 |
Partially correct |
45 ms |
344 KB |
Partially correct |
91 |
Partially correct |
59 ms |
344 KB |
Partially correct |
92 |
Partially correct |
169 ms |
344 KB |
Partially correct |
93 |
Partially correct |
214 ms |
344 KB |
Partially correct |
94 |
Partially correct |
42 ms |
344 KB |
Partially correct |
95 |
Partially correct |
70 ms |
340 KB |
Partially correct |
96 |
Partially correct |
203 ms |
932 KB |
Partially correct |
97 |
Correct |
0 ms |
344 KB |
Output is correct |