Submission #1049314

#TimeUsernameProblemLanguageResultExecution timeMemory
1049314vjudge1Light Bulbs (EGOI24_lightbulbs)C++17
22 / 100
60 ms716 KiB
#include <bits/stdc++.h> using namespace std; #define ar array #define int long long #define ld long double #pragma GCC optimize("O3,unroll-loops") #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") const int N = 200; const int X = N * N; const int K = 500; const int MOD = 1e9 + 7; const int LOG = 21; const int INF = 1e17; string ans[N]; int n; int ask(int a, int b,int c,int d){ string s[n]; for(int i = 0;i < n;i++)s[i] = string(n, '0'); s[a][b] = '1'; s[c][d] = '1'; cout<<"?"<<endl; for(int i = 0;i < n;i++)cout<<s[i]<<endl; int x; cin>>x; return x; } void find(int x,int y){ if(ans[x][y] != '$')return; for(int i = 0;i < n;i++){ if(ans[x][i] != '$'){ if(ask(x, i, x, y) == 2 * n - 1)ans[x][y] = (ans[x][i] == 'V' ? 'H' : 'V'); else ans[x][y] = ans[x][i]; return; } if(ans[i][y] != '$'){ if(ask(i, y, x, y) == 2 * n - 1)ans[x][y] = (ans[i][y] == 'V' ? 'H' : 'V'); else ans[x][y] = ans[i][y]; return; } } } bitset<N> res[N]; void hor(){ for(int i = 0;i < n;i++){ for(int j = 0;j < n;j++){ if(ans[i][j] == 'H'){ res[i][j] = 1; break; } } } } void vert(){ for(int i = 0;i < n;i++){ for(int j = 0;j < n;j++){ if(ans[j][i] == 'V'){ res[j][i] = 1; break; } } } } signed main(){ios::sync_with_stdio(false);cin.tie(0); cin>>n; for(int i = 0;i < n;i++)ans[i] = string(n, '$'); int x = ask(0, 0, 0, 1); if(x == 2 * n)ans[0][0] = ans[0][1] = 'V'; else if(x == n)ans[0][0] = ans[0][1] = 'H'; else{ x = ask(0, 0, 0, 2); if(x == 2 * n)ans[0][0] = ans[0][2] = 'V', ans[0][1] = 'H'; else if(x == n)ans[0][0] = ans[0][2] = 'H', ans[0][1] = 'V'; else{ x = ask(0, 1, 0, 2); if(x == 2 * n)ans[0][1] = ans[0][2] = 'V', ans[0][0] = 'H'; else if(x == n)ans[0][1] = ans[0][2] = 'H', ans[0][0] = 'V'; } } for(int i = 0;i < n;i++){ for(int j = 0;j < n;j++){ find(i, j); } } bool h = 1; for(int i = 0;i < n;i++){ bool b = 0; for(int j = 0;j < n;j++){ if(ans[i][j] == 'H'){ b = 1; break; } } if(!b){ h = 0; break; } } if(h)hor(); else vert(); cout<<"!"<<endl; for(int i = 0;i < n;i++){ for(int j = 0;j < n;j++){ cout<<res[i][j]; } cout<<endl; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...