답안 #1058773

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1058773 2024-08-14T13:36:29 Z Gray Light Bulbs (EGOI24_lightbulbs) C++17
79.9678 / 100
106 ms 532 KB
// #pragma GCC optimize("O3")
// #pragma GCC target("avx2")
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <functional>
#include <map>
#include <math.h>
#include <algorithm>
#include <iostream>
#include <queue>
#include <set>
#include <utility>
#include<string>
#include <vector>
#define ll long long
#define ull unsigned ll
#define ld long double
#define ln "\n"
#define ff first
#define ss second
using namespace std;
const ll inf=2e18;
const ll MOD = 1000000007;
ll n;
ll query(vector<pair<ll, ll>> pts){
	cout << "?" << endl;
	vector<vector<ll>> out(n, vector<ll>(n));
	for (auto ch:pts){
		out[ch.ff][ch.ss]=1;
	}
	for (ll i=0; i<n; i++){
		for (ll j=0; j<n; j++) cout << out[i][j];
		cout << endl;
	}
	ll x; cin >> x; return x;
}
void solve(){
	cin >> n;
	ll ic=0, jc=0;
	vector<ll> ver(n), hor(n);
	pair<ll, ll> mv;
	{
		ll qry=query({{0, 0}, {0, 1}});
		if (qry==2*n){
			mv = {0, 1};
		}else if (qry==n){
			mv = {1, 0};
		}else{
			qry=query({{0, 0}, {0, 2}});
			if (qry==2*n){
				mv = {0, 1};
			}else if (qry==n){
				mv = {1, 0};
			}else{
				qry=query({{0, 1}, {0, 2}});
				if (qry==2*n){
					mv = {1, 0};
				}else{
					mv = {0, 1};
				}
			}
		}
	}
	if (mv==make_pair(0ll, 1ll)){
		ver[0]=0;
		jc++;
	}else{
		hor[0]=0;
		ic++;
	}
	// ll cnt=0;
	while (ic<n and jc<n){
		// cout << "Program: " << ic << " " << jc << ln;
		ll pic = ic-mv.ff, pjc=jc-mv.ss;
		ll qry=query({{pic, pjc}, {ic, jc}});
		if (qry==2*n){
			if (mv == make_pair(0ll, 1ll)){
				ver[jc]=ic;
				jc++;
			}else{
				hor[ic]=jc;
				ic++;
			}
		}else{
			swap(mv.ff, mv.ss);
			if (mv == make_pair(0ll, 1ll)){
				ver[jc]=ic;
				jc++;
			}else{
				hor[ic]=jc;
				ic++;
			}			
		}
		if (ic==n or jc==n) break;
	}
	vector<vector<ll>> ans(n, vector<ll>(n));
	// cerr << ic << " " << jc << ln;
	if (ic==n){
		for (ll i=0; i<n; i++){
			ans[i][hor[i]]=1;
		}
	}else{
		for (ll i=0; i<n; i++){
			ans[ver[i]][i]=1;
		}
	}
	
	cout << "!" << endl;
	for (ll i=0; i<n; i++){
		for (ll j=0; j<n; j++){
			cout << ans[i][j];
		}
		cout << ln;
	}
}
int main(){
	// freopen("error.f", "w", stderr);
	ios_base::sync_with_stdio(0);
	cin.tie(nullptr);
	ll t=1;
	// cin >> t;
	while (t--) solve();
}
# 결과 실행 시간 메모리 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
# 결과 실행 시간 메모리 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 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 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 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 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 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 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 0 ms 344 KB Output is correct
51 Correct 0 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 0 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 0 ms 344 KB Output is correct
59 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 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 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 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 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 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 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 0 ms 344 KB Output is correct
39 Correct 0 ms 344 KB Output is correct
40 Correct 1 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 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 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 0 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 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 0 ms 344 KB Output is correct
58 Correct 0 ms 344 KB Output is correct
59 Partially correct 62 ms 344 KB Partially correct
60 Partially correct 32 ms 532 KB Partially correct
61 Partially correct 35 ms 344 KB Partially correct
62 Partially correct 39 ms 344 KB Partially correct
63 Partially correct 45 ms 344 KB Partially correct
64 Partially correct 53 ms 344 KB Partially correct
65 Partially correct 57 ms 344 KB Partially correct
66 Partially correct 62 ms 344 KB Partially correct
67 Partially correct 49 ms 516 KB Partially correct
68 Partially correct 51 ms 516 KB Partially correct
69 Partially correct 35 ms 344 KB Partially correct
70 Partially correct 43 ms 512 KB Partially correct
71 Partially correct 37 ms 344 KB Partially correct
72 Partially correct 32 ms 340 KB Partially correct
73 Partially correct 42 ms 344 KB Partially correct
74 Partially correct 86 ms 344 KB Partially correct
75 Partially correct 38 ms 344 KB Partially correct
76 Partially correct 39 ms 532 KB Partially correct
77 Partially correct 42 ms 344 KB Partially correct
78 Partially correct 40 ms 344 KB Partially correct
79 Partially correct 35 ms 344 KB Partially correct
80 Partially correct 41 ms 344 KB Partially correct
81 Partially correct 60 ms 344 KB Partially correct
82 Partially correct 87 ms 512 KB Partially correct
83 Partially correct 61 ms 344 KB Partially correct
84 Partially correct 46 ms 344 KB Partially correct
85 Partially correct 106 ms 508 KB Partially correct
86 Partially correct 104 ms 344 KB Partially correct
87 Partially correct 56 ms 512 KB Partially correct
88 Partially correct 33 ms 344 KB Partially correct
89 Partially correct 33 ms 344 KB Partially correct
90 Partially correct 44 ms 344 KB Partially correct
91 Partially correct 49 ms 344 KB Partially correct
92 Partially correct 59 ms 344 KB Partially correct
93 Partially correct 49 ms 344 KB Partially correct
94 Partially correct 61 ms 340 KB Partially correct
95 Partially correct 53 ms 344 KB Partially correct
96 Partially correct 103 ms 344 KB Partially correct
97 Correct 0 ms 344 KB Output is correct