Submission #1058689

#TimeUsernameProblemLanguageResultExecution timeMemory
1058689Zbyszek99Light Bulbs (EGOI24_lightbulbs)C++17
0 / 100
0 ms344 KiB
#include <bits/stdc++.h> #define ll long long #define ld long double #define ff first #define ss second #define pii pair<int,int> #define pll pair<long long, long long> #define pb push_back #define rep(i, b) for(int i = 0; i < (b); ++i) #define rep2(i,a,b) for(int i = a; i <= (b); ++i) #define rep3(i,a,b,c) for(int i = a; i <= (b); i+=c) #define count_bits(x) __builtin_popcountll((x)) #define all(x) (x).begin(),(x).end() #define size(x) (int)(x).size() #define forall(it,x) for(auto& it:(x)) using namespace std; //mt19937 mt;void random(){mt.seed(chrono::time_point_cast<chrono::milliseconds>(chrono::high_resolution_clock::now()).time_since_epoch().count());} //ll rand(ll a, ll b) {return a + (mt() % (b-a+1));} const int INF = 1e9+50; const ll INF_L = 1e18+40; const ll MOD = 1e9+7; int n; int ans_[100][100]; int ask(vector<pii> v) { string q = "?\n"; set<pii> s; forall(it,v) s.insert(it); rep(i,n) { rep(j,n) { if(s.find({i,j}) == s.end()) { q += '0'; } else { q += '1'; } } q += '\n'; } cout << q; cout.flush(); int ans; cin >> ans; cout.flush(); return ans; } int check_seg(int i, int l, int r) { vector<pii> v; rep2(j,l,r) v.pb({i,j}); return ask(v); } void solve() { cin >> n; cout.flush(); rep(i,n) { if(check_seg(i,0,n-1) == n*n) { cout << "!\n"; rep(i2,n) { rep(j,n) { if(i2 == i) cout << "1"; else cout << "0\n"; } cout << "\n"; } cout.flush(); return; } } vector<int> dont_know; pii ok = {-1,-1}; rep(i,n) { int pocz = 0; int kon = n-1; int ans = -1; while(pocz <= kon) { int mid = (pocz+kon+1)/2; if(mid == 0) { ans = -1; dont_know.pb(i); break; } int a = check_seg(i,0,mid); if(a == n) { ans = mid; break; } if(a % n == 0) { pocz = mid+1; } else { kon = mid-1; ans = mid; } } if(ans != -1) { ok = {i,ans}; ans_[i][ans] = 1; } } if(ok.ff == -1) { bool was_ = true; rep2(j,1,n-1) { if(ask({{0,0},{0,j}}) == n*2) was_ = false; } if(!was_) { ok = {0,1}; ans_[0][1] = 1; } else { if(ask({{0,1},{0,2}}) == n) { ok = {0,1}; ans_[0][1] = 1; } else { ok = {0,0}; ans_[0][0] = 1; } } } forall(it,dont_know) { if(it == ok.ff) continue; if(ask({ok,{it,0}}) == n*2) { ans_[it][0] = 1; } else ans_[it][1] = 1; } string z = "!\n"; rep(i,n) { rep(j,n) { if(ans_[i][j] == 1) z += '1'; else z += '0'; } z += '\n'; } cout << z; cout.flush(); } int main() { //ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); //random(); 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...