Submission #1315464

#TimeUsernameProblemLanguageResultExecution timeMemory
1315464salmonLight Bulbs (EGOI24_lightbulbs)C++20
0 / 100
6 ms416 KiB
#include <bits/stdc++.h>
using namespace std;

mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());

int N;
bool ans[110][110];

void print(){
	printf("?\n");
	
	for(int i = 0; i < N; i++){
		for(int j = 0; j < N; j++) printf("%d",(int)ans[i][j]);
		printf("\n");
	}
	
	fflush(stdout);
}

int query(){
	print();
	
	int h;
	scanf(" %d",&h);

	return h;
}

void reset(){
	for(int i = 0; i < N; i++){
		for(int j = 0; j < N; j++){
			ans[i][j] = 0;
		}
	}
}

void answer(){
	printf("!\n");
	
	for(int i = 0; i < N; i++){
		for(int j = 0; j < N; j++) printf("%d",(int)ans[i][j]);
		printf("\n");
	}
	
	fflush(stdout);
}


int main(){
	scanf(" %d",&N);
	
	vector<pair<int,int>> v;
	
	for(int i = 0; i < N; i++){
		for(int j = 0; j < N; j++){
			v.push_back({i,j});
		}
	}
	
	int buc = 50;
	
	while(true) query();
	
	while(v.size() != N){
		vector<pair<int,int>> temp;
		
		shuffle(v.begin(),v.end(), rng);
		
		for(int i = 0; i < min((int)v.size() - N, buc); i++){
			temp.push_back(v.back());
			v.pop_back();
		}
		
		reset();
		for(pair<int,int> ii : v) ans[ii.first][ii.second] = 1;
		if(query()==N * N) continue;
		
		for(pair<int,int> ii : temp) v.push_back(ii);
	}
	
	reset();
	for(pair<int,int> ii : v) ans[ii.first][ii.second] = 1;
	
	answer();
}

Compilation message (stderr)

Main.cpp: In function 'int query()':
Main.cpp:24:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 |         scanf(" %d",&h);
      |         ~~~~~^~~~~~~~~~
Main.cpp: In function 'int main()':
Main.cpp:50:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   50 |         scanf(" %d",&N);
      |         ~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...