Submission #1305121

#TimeUsernameProblemLanguageResultExecution timeMemory
1305121salmonLight Bulbs (EGOI24_lightbulbs)C++20
80 / 100
70 ms452 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]; bool ansh[110][110]; bool ansv[110][110]; int buf; vector<int> h,v; 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); } 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); } bool check(int i, int j){ if(ansh[0][0]){ for(int i = 0; i < N; i++){ for(int j = 0; j < N; j++){ ans[i][j] = 0; } } ans[0][0] = 1; ans[i][j] = 1; print(); int h; scanf(" %d",&h); if(h % N == 0) return 1; return 0; } else{ for(int i = 0; i < N; i++){ for(int j = 0; j < N; j++){ ans[i][j] = 0; } } ans[0][0] = 1; ans[i][j] = 1; print(); int h; scanf(" %d",&h); if(h % N == 0) return 0; return 1; } } int main(){ scanf(" %d",&N); for(int i = 0; i < N; i++){ h.push_back(i); v.push_back(i); } for(int i = 0; i < N; i++){ for(int j = 0; j < N; j++){ ans[i][j] = false; ansh[i][j] = false; ansv[i][j] = false; } } for(int j = 0; j < N; j++){ ans[0][j] = true; } print(); scanf(" %d",&buf); if(buf == N * N){ answer(); return 0; } int num1 = buf; ans[0][0] = false; print(); scanf(" %d",&buf); if(buf % N == 0 && buf != N){ ansh[0][0] = 1; h.erase(h.begin(),h.begin() + 1); } else{ if(buf == num1){ ansh[0][0] = 1; h.erase(h.begin(),h.begin() + 1); } else{ ansv[0][0] = 1; v.erase(v.begin(),v.begin() + 1); } } while(!h.empty() && !v.empty()){ //for(int i : h) printf("%d ",i); //printf("\n"); //for(int i : v) printf("%d ",i); //printf("\n\n"); int x = rng() % h.size(); int y = rng() % v.size(); if(check(h[x],v[y])){ ansh[h[x]][v[y]] = 1; h.erase(h.begin() + x, h.begin() + x + 1); } else{ ansv[h[x]][v[y]] = 1; v.erase(v.begin() + y, v.begin() + y + 1); } } if(h.empty()){ for(int i = 0; i < N; i++){ for(int j = 0; j < N; j++){ ans[i][j] = ansh[i][j]; } } } else if(v.empty()){ for(int i = 0; i < N; i++){ for(int j = 0; j < N; j++){ ans[i][j] = ansv[i][j]; } } } answer(); }

Compilation message (stderr)

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