답안 #1048359

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1048359 2024-08-08T07:03:54 Z 이온조(#11092) Light Bulbs (EGOI24_lightbulbs) C++17
57.38 / 100
429 ms 1444 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;
	cnt = N;
	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);
	}
	return 0;
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:42:19: 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=0; i<(V.size()+1)/2; i++) L.push_back(V[i]);
      |                  ~^~~~~~~~~~~~~~~
Main.cpp:43:32: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |     for(int i=(V.size()+1)/2; i<V.size(); i++) R.push_back(V[i]);
      |                               ~^~~~~~~~~
Main.cpp:44:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |     if(l = query(L, 0) < N * L.size()) V = L;
      |            ~~~~~~~~~~~~^~~~~~~~~~~~~~
Main.cpp:44:10: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   44 |     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);
      |  ~~~~~^~~~~~~~~~
# 결과 실행 시간 메모리 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 1 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 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 596 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 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 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 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 1 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 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 1 ms 344 KB Output is correct
46 Correct 1 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 0 ms 344 KB Output is correct
52 Correct 1 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 1 ms 344 KB Output is correct
57 Correct 1 ms 344 KB Output is correct
58 Correct 1 ms 344 KB Output is correct
59 Correct 0 ms 344 KB Output is correct
# 결과 실행 시간 메모리 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 1 ms 344 KB Output is correct
6 Correct 0 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 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 1 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 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 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 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 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 1 ms 344 KB Output is correct
46 Correct 1 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 1 ms 344 KB Output is correct
52 Correct 1 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 1 ms 344 KB Output is correct
56 Correct 1 ms 344 KB Output is correct
57 Correct 0 ms 360 KB Output is correct
58 Correct 0 ms 344 KB Output is correct
59 Partially correct 37 ms 480 KB Partially correct
60 Partially correct 54 ms 340 KB Partially correct
61 Partially correct 286 ms 708 KB Partially correct
62 Partially correct 268 ms 344 KB Partially correct
63 Partially correct 258 ms 464 KB Partially correct
64 Partially correct 193 ms 464 KB Partially correct
65 Partially correct 219 ms 344 KB Partially correct
66 Partially correct 187 ms 700 KB Partially correct
67 Partially correct 195 ms 344 KB Partially correct
68 Partially correct 201 ms 344 KB Partially correct
69 Partially correct 136 ms 484 KB Partially correct
70 Partially correct 124 ms 736 KB Partially correct
71 Partially correct 118 ms 480 KB Partially correct
72 Partially correct 312 ms 464 KB Partially correct
73 Partially correct 391 ms 464 KB Partially correct
74 Partially correct 399 ms 692 KB Partially correct
75 Partially correct 64 ms 344 KB Partially correct
76 Partially correct 50 ms 476 KB Partially correct
77 Partially correct 51 ms 344 KB Partially correct
78 Partially correct 282 ms 472 KB Partially correct
79 Partially correct 81 ms 928 KB Partially correct
80 Partially correct 246 ms 344 KB Partially correct
81 Partially correct 37 ms 344 KB Partially correct
82 Partially correct 342 ms 1444 KB Partially correct
83 Partially correct 35 ms 344 KB Partially correct
84 Partially correct 191 ms 480 KB Partially correct
85 Partially correct 353 ms 464 KB Partially correct
86 Partially correct 53 ms 344 KB Partially correct
87 Partially correct 399 ms 468 KB Partially correct
88 Partially correct 330 ms 708 KB Partially correct
89 Partially correct 35 ms 344 KB Partially correct
90 Partially correct 310 ms 468 KB Partially correct
91 Partially correct 415 ms 344 KB Partially correct
92 Partially correct 187 ms 472 KB Partially correct
93 Partially correct 200 ms 344 KB Partially correct
94 Partially correct 429 ms 344 KB Partially correct
95 Partially correct 66 ms 344 KB Partially correct
96 Partially correct 233 ms 460 KB Partially correct
97 Correct 0 ms 344 KB Output is correct