답안 #1048256

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1048256 2024-08-08T06:05:32 Z 박영우(#11091) Light Bulbs (EGOI24_lightbulbs) C++17
63.7922 / 100
345 ms 972 KB
//#define LOCAL
#include <bits/stdc++.h>
#include <cassert>
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx,avx2,fma")
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
#define MAX 110
#define MAXQ 101010
#define INF 1'000'000'100'000'000'000
#define bb ' '
#define ln '\n'
#define Ln '\n'
#define MOD 1000000007
#define TC 1
#ifdef LOCAL
#define DEBUG(a) cout<<a
#define TEST true
#else
#define DEBUG(...) 1234
#define TEST false
#endif

int mp[MAX][MAX];
int ans[MAX];
int N;
int dp[MAX][MAX];
int arr[MAX][MAX];
int query(char x = '?') {
	cout << x << endl;
	int i, j;
	for (i = 0; i < N; i++) {
		for (j = 0; j < N; j++) cout << arr[i][j];
		cout << endl;
	}
	if (x == '?') {
		int x;
		cin >> x;
		return x;
	}
	return 0;
}
int test(int r, int c) {
	if (dp[r][c]) return dp[r][c];
	int i, j;
	cout << '?' << endl;
	for (i = 0; i < N; i++) {
		for (j = 0; j < N; j++) {
			if (i <= r && j == c) cout << 1;
			else cout << 0;
		}
		cout << endl;
	}
	int x;
	cin >> x;
	return dp[r][c] = x;
}
int get(int sum, int mul) {
	int i;
	for (i = 0; i <= sum; i++) {
		int j = sum - i;
		if (i * j == mul) return i;
	}
	assert(0);
	return 0;
}
int chk[MAX];
signed main() {
	ios::sync_with_stdio(false), cin.tie(0);
	cin >> N;
	int i;
	for (i = 0; i < N; i++) {
		int l, r;
		l = 0;
		r = N;
		while (r - l > 1) {
			if (r == 1) break;
			int m = l + r >> 1;
			int res = test(m, i);
			if (res == N * (m + 1)) l = m;
			else r = m;
		}
		if (r == 1) {
			chk[i] = 1;
			continue;
		}
		if (r == N) {
			int a, b;
			cout << '!' << endl;
			for (a = 0; a < N; a++) {
				for (b = 0; b < N; b++) {
					if (b == i) cout << 1;
					else cout << 0;
				}
				cout << endl;
			}
			return 0;
		}
		ans[i] = r;
	}
	vector<int> vc, nc;
	for (i = 0; i < N; i++) if (chk[i]) vc.push_back(i);
	for (i = 0; i < N; i++) if (!chk[i]) nc.push_back(i);
	if (nc.empty()) {
		int x, y, z;
		int sz = vc.size();
		x = vc[sz - 1], y = vc[sz - 2], z = vc[sz - 3];
		int chk = 0;
		for (ans[x] = 0; ans[x] <= 1; ans[x]++) {
			for (ans[y] = 0; ans[y] <= 1; ans[y]++) {
				for (ans[z] = 0; ans[z] <= 1; ans[z]++) {
					arr[ans[x]][x] = arr[ans[y]][y] = arr[ans[z]][z] = 1;
					if (query() == N * 3) chk = 1;
					arr[ans[x]][x] = arr[ans[y]][y] = arr[ans[z]][z] = 0;
					if (chk) break;
				}
				if (chk) break;
			}
			if (chk) break;
		}
		vc.pop_back();
		vc.pop_back();
		vc.pop_back();
		nc.push_back(x);
		nc.push_back(y);
		nc.push_back(z);
	}
	for (auto x : vc) {
		arr[ans[nc[0]]][nc[0]] = 1;
		arr[0][x] = 1;
		if (query() == N * 2) ans[x] = 0;
		else ans[x] = 1;
		arr[ans[nc[0]]][nc[0]] = 0;
		arr[0][x] = 0;
	}
	for (i = 0; i < N; i++) arr[ans[i]][i] = 1;
	query('!');
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:82:14: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   82 |    int m = l + r >> 1;
      |            ~~^~~
# 결과 실행 시간 메모리 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
# 결과 실행 시간 메모리 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 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 1 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 0 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 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 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 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 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 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 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 1 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 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 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 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 1 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 1 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 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 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 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 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 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 340 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 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 1 ms 460 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 344 KB Output is correct
58 Correct 1 ms 344 KB Output is correct
59 Correct 5 ms 344 KB Output is correct
60 Partially correct 276 ms 468 KB Partially correct
61 Partially correct 227 ms 460 KB Partially correct
62 Partially correct 201 ms 344 KB Partially correct
63 Partially correct 208 ms 596 KB Partially correct
64 Partially correct 224 ms 344 KB Partially correct
65 Partially correct 217 ms 452 KB Partially correct
66 Partially correct 196 ms 588 KB Partially correct
67 Partially correct 217 ms 344 KB Partially correct
68 Partially correct 215 ms 456 KB Partially correct
69 Partially correct 205 ms 344 KB Partially correct
70 Partially correct 220 ms 452 KB Partially correct
71 Partially correct 198 ms 344 KB Partially correct
72 Partially correct 225 ms 344 KB Partially correct
73 Partially correct 171 ms 608 KB Partially correct
74 Partially correct 345 ms 448 KB Partially correct
75 Correct 4 ms 344 KB Output is correct
76 Partially correct 35 ms 344 KB Partially correct
77 Partially correct 138 ms 452 KB Partially correct
78 Partially correct 183 ms 600 KB Partially correct
79 Partially correct 50 ms 708 KB Partially correct
80 Partially correct 147 ms 344 KB Partially correct
81 Partially correct 197 ms 460 KB Partially correct
82 Partially correct 197 ms 700 KB Partially correct
83 Partially correct 196 ms 344 KB Partially correct
84 Partially correct 285 ms 972 KB Partially correct
85 Partially correct 191 ms 344 KB Partially correct
86 Partially correct 177 ms 344 KB Partially correct
87 Partially correct 212 ms 460 KB Partially correct
88 Partially correct 204 ms 592 KB Partially correct
89 Partially correct 209 ms 456 KB Partially correct
90 Partially correct 187 ms 344 KB Partially correct
91 Partially correct 186 ms 460 KB Partially correct
92 Partially correct 198 ms 344 KB Partially correct
93 Partially correct 214 ms 468 KB Partially correct
94 Partially correct 201 ms 460 KB Partially correct
95 Partially correct 184 ms 592 KB Partially correct
96 Partially correct 230 ms 344 KB Partially correct
97 Correct 1 ms 344 KB Output is correct