Submission #1156368

#TimeUsernameProblemLanguageResultExecution timeMemory
1156368emptypringlescanLight Bulbs (EGOI24_lightbulbs)C++20
80 / 100
61 ms476 KiB
#include <bits/stdc++.h>
using namespace std;
int32_t main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    int arr[n][n];
    for(int i=0; i<n; i++){
		for(int j=0; j<n; j++){
			arr[i][j]=0;
		}
	}
	int r=0,c=0;
	vector<pair<int,int> > vert,hori;
	while(r<n&&c<n){
		if(r==0&&c==0){
			cout << "?" << endl;
			for(int i=0; i<n; i++) cout << 1;
			cout << endl;
			for(int i=1; i<n; i++){
				for(int j=0; j<n; j++) cout << 0;
				cout << endl;
			}
			int x;
			cin >> x;
			cout << "?" << endl;
			cout << 0;
			for(int i=1; i<n; i++) cout << 1;
			cout << endl;
			for(int i=1; i<n; i++){
				for(int j=0; j<n; j++) cout << 0;
				cout << endl;
			}
			int y;
			cin >> y;
			if(y>=x-1){
				hori.push_back({r,c});
				r++;
			}
			else{
				vert.push_back({r,c});
				c++;
			}
		}
		else if(r){
			cout << '?' << endl;
			for(int i=0; i<n; i++){
				for(int j=0; j<n; j++){
					if(i==r&&j==c) cout << 1;
					else if(i==hori.back().first&&j==hori.back().second) cout << 1;
					else cout << 0;
				}
				cout << endl;
			}
			int x;
			cin >> x;
			if(x!=n*2-1){
				hori.push_back({r,c});
				r++;
			}
			else{
				vert.push_back({r,c});
				c++;
			}
		}
		else{
			cout << '?' << endl;
			for(int i=0; i<n; i++){
				for(int j=0; j<n; j++){
					if(i==r&&j==c) cout << 1;
					else if(i==vert.back().first&&j==vert.back().second) cout << 1;
					else cout << 0;
				}
				cout << endl;
			}
			int x;
			cin >> x;
			if(x!=n*2-1){
				vert.push_back({r,c});
				c++;
			}
			else{
				hori.push_back({r,c});
				r++;
			}
		}
	}
	if(r==n){
		for(auto i:hori){
			arr[i.first][i.second]=1;
		}
	}
	else{
		for(auto i:vert){
			arr[i.first][i.second]=1;
		}
	}
	cout << '!' << endl;
	for(int i=0; i<n; i++){
		for(int j=0; j<n; j++) cout << arr[i][j];
		cout << endl;
	}
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...