Submission #1048267

# Submission time Handle Problem Language Result Execution time Memory
1048267 2024-08-08T06:09:55 Z 김은성(#11035) Light Bulbs (EGOI24_lightbulbs) C++17
54.2222 / 100
480 ms 1288 KB
#include <bits/stdc++.h>
using namespace std;
bool q[109][109], a[109][109];
int n;
int ask(){
	printf("?\n");
	for(int i=0; i<n; i++){
		for(int j=0; j<n; j++){
			printf("%d", q[i][j]);
		}
		printf("\n");
	}
	fflush(stdout);
	int val;
	scanf("%d", &val);
	return val;
}
void answer(){
	printf("!\n");
	for(int i=0; i<n; i++){
		for(int j=0; j<n; j++){
			printf("%d", a[i][j]);
		}
		printf("\n");
	}
	fflush(stdout);
}
int main(){
	scanf("%d", &n);
	int i, j;
	for(i=0; i<n; i++){
		int lo = 0, hi = n-1, mid;
		memset(q, 0, sizeof(q));
		for(j=0; j<n; j++)
			q[i][j] = 1;
		if(ask() == n*n){
			memset(a, 0, sizeof(a));
			for(int j=0; j<n; j++)
				a[i][j] = 1;
			answer();
			return 0;
		}
		while(lo < hi){
			mid = (lo+hi)/2;
			memset(q, 0, sizeof(q));
			if(hi-lo == 2){
				q[i][lo] = q[i][lo+1] = 1;
				if(ask() == n * 2)
					lo += 2;
				else{
					q[i][lo] = 0;
					q[i][lo+2] = 1;
					if(ask() == n*2)
						hi = lo;
					else{
						q[i][lo+1] = 0;
						q[i][lo] = 1;
						if(ask() == n)
							hi = lo;
						else
							hi = lo = lo+1;
					}
				}
				continue;
			}
			if(hi-lo == 3)
				mid++;
			else if(hi-lo == 4)
				mid++;
			for(int j=lo; j<=mid; j++)
				q[i][j] = 1;
			if(ask() == n * (mid-lo+1))
				lo = mid+1;
			else
				hi = mid;
		}
		a[i][lo] = 1;
	}
	answer();
	return 0;
}

Compilation message

Main.cpp: In function 'int ask()':
Main.cpp:15:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |  scanf("%d", &val);
      |  ~~~~~^~~~~~~~~~~~
Main.cpp: In function 'int main()':
Main.cpp:29:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   29 |  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 1 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 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 1 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 1 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 1 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 596 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 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 1 ms 344 KB Output is correct
38 Correct 1 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 1 ms 344 KB Output is correct
44 Correct 1 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 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 1 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 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 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 1 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 1 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 1 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 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 1 ms 344 KB Output is correct
35 Correct 1 ms 344 KB Output is correct
36 Correct 1 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 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 0 ms 344 KB Output is correct
43 Correct 1 ms 344 KB Output is correct
44 Correct 1 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 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 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 1 ms 344 KB Output is correct
59 Partially correct 459 ms 688 KB Partially correct
60 Correct 2 ms 344 KB Output is correct
61 Partially correct 419 ms 1056 KB Partially correct
62 Partially correct 417 ms 592 KB Partially correct
63 Partially correct 406 ms 896 KB Partially correct
64 Partially correct 376 ms 808 KB Partially correct
65 Partially correct 409 ms 428 KB Partially correct
66 Partially correct 396 ms 788 KB Partially correct
67 Partially correct 394 ms 592 KB Partially correct
68 Partially correct 400 ms 432 KB Partially correct
69 Partially correct 365 ms 900 KB Partially correct
70 Partially correct 339 ms 344 KB Partially correct
71 Partially correct 331 ms 920 KB Partially correct
72 Correct 1 ms 344 KB Output is correct
73 Partially correct 136 ms 428 KB Partially correct
74 Partially correct 237 ms 432 KB Partially correct
75 Partially correct 407 ms 684 KB Partially correct
76 Partially correct 331 ms 424 KB Partially correct
77 Partially correct 301 ms 572 KB Partially correct
78 Partially correct 108 ms 444 KB Partially correct
79 Partially correct 379 ms 596 KB Partially correct
80 Partially correct 443 ms 432 KB Partially correct
81 Partially correct 402 ms 432 KB Partially correct
82 Partially correct 480 ms 668 KB Partially correct
83 Partially correct 363 ms 1092 KB Partially correct
84 Partially correct 387 ms 344 KB Partially correct
85 Partially correct 439 ms 1128 KB Partially correct
86 Partially correct 427 ms 436 KB Partially correct
87 Partially correct 326 ms 428 KB Partially correct
88 Partially correct 414 ms 1288 KB Partially correct
89 Partially correct 354 ms 344 KB Partially correct
90 Partially correct 406 ms 820 KB Partially correct
91 Partially correct 400 ms 344 KB Partially correct
92 Partially correct 400 ms 692 KB Partially correct
93 Partially correct 381 ms 668 KB Partially correct
94 Partially correct 435 ms 344 KB Partially correct
95 Partially correct 424 ms 1136 KB Partially correct
96 Partially correct 392 ms 424 KB Partially correct
97 Correct 1 ms 344 KB Output is correct