Submission #1151718

#TimeUsernameProblemLanguageResultExecution timeMemory
1151718RafiullahLight Bulbs (EGOI24_lightbulbs)C++20
0 / 100
1 ms436 KiB
#include<bits/stdc++.h> // #include <ext/pb_ds/tree_policy.hpp> // #include <ext/pb_ds/assoc_container.hpp> using namespace std; #define int long long const int N = 5e5 + 5; const int mod = 1e9 + 7; const int mod1 = 998244353; const int LG = 20; // #define s(i) (*s.find_by_order(i)) // Warning : Read this line. int power(int b,int e){ if(e<=0)return 1; int o = power(b,e>>1); o *= o, o %= mod1; if(e % 2)o *= b, o %= mod1; return o; } void solve(){ int n;cin >> n; int y; for(int i = 1 ; i <= n ; i ++){ cout << "?" << endl; for(int j = 1 ; j < i ; j ++){ for(int k = 1 ; k <= n ; k ++) cout << 0 ; cout << endl; } for(int j = 1 ; j <= n ;j ++)cout << 1 ; cout << endl; for(int j = i+1 ; j <=n ; j ++){ for(int k = 1 ; k <= n ; k ++) cout << 0 ; cout << endl; } cin >> y; if(y == n * n){ cout << "!" << endl; for(int j = 1 ; j < i ; j ++){ for(int k = 1 ; k <= n ; k ++) cout << 0 ; cout << endl; } for(int j = 1 ; j <= n ;j ++)cout << 1 ; cout << endl; for(int j = i+1 ; j <=n ; j ++){ for(int k = 1 ; k <= n ; k ++) cout << 0 ; cout << endl; } return; } } for(int j = 1 ; j <= n ; j ++){ vector<vector<int>> V(n + 1,vector<int>(n + 1)); for(int i = 1 ; i <= n ; i++) V[i][j] = 1; cout << "? " << endl; for(int i = 1 ; i <= n ; i ++){ for(int t = 1 ;t <= n ;t ++) cout << V[i][t] ; cout << endl; } cin >> y; if(y == n * n){ cout << "! " << endl; for(int i = 1 ; i <= n ; i ++){ for(int t = 1 ;t <= n ;t ++) cout << V[i][t] ; cout << endl; } cout << endl; return; } } vector<vector<int>> ans(n + 1,vector<int>(n + 1)); for(int row = 1 ; row <= n ; row ++){ bool f = false; for(int i = 1 ; i <= n ; i ++){ for(int j = i + 1 ; j <= n ; j ++){ vector<vector<int>> T(n+1,vector<int>(n+1)); T[row][i] = T[row][j] = 1; cout << "? " << endl; for(int i1 = 1 ; i1 <= n ; i1 ++){ for(int i2 = 1 ; i2 <= n ; i2 ++) cout << T[i1][i2] ; cout << endl; } cin >> y; if(y == n){ ans[row][i] = 1;f=true; } if(f)break; } if(f)break; } if(f)continue; vector<int> E; for(int i = 1 ; i < n ; i ++){ vector<vector<int>> T(n+1,vector<int>(n+1)); T[row][i] = T[row][i+1] = 1; cout << "?" << endl; for(int i1 = 1 ; i1 <= n ; i1 ++){ for(int i2 = 1 ; i2 <= n ; i2 ++) cout << T[i1][i2] ; cout << endl; } cin >> y; if(y == 2 * n - 1) E.push_back(i); if(i == 1 and E.size())f=true; } if(E.size() == 2) ans[row][E.back()] = 1; else if(f) ans[row][1] = 1; else ans[row][n] = 1; } cout << "! " << endl; for(int i = 1 ; i <= n ; i ++){ for(int j = 1 ; j <= n ; j ++) cout << ans[i][j]; cout << endl; } } signed main(){ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); int t = 1; // cin >> t; while(t --){ solve(); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...