Submission #920468

#TimeUsernameProblemLanguageResultExecution timeMemory
920468zeta7532Zagrade (COI20_zagrade)C++17
71 / 100
568 ms5432 KiB
#include <bits/stdc++.h> #pragma GCC target("avx2") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") using namespace std; using ll = long long; const ll mod = 998244353; #define fi first #define se second #define rep(i,n) for(ll i=0;i<n;i++) #define all(x) x.begin(),x.end() #define faster ios::sync_with_stdio(false);cin.tie(nullptr) int main() { ll N,Q; cin >> N >> Q; vector<char> ans(N,'-'); ll l=0; ans[0]='('; ll r=1; set<ll> s; rep(i,N) s.insert(i); while(1){ if(r>=N) break; cout << "?" << " " << l+1 << " " << r+1 << endl; ll q; cin >> q; if(q==0){ ans[r]='('; l=r; r=l+1; } if(q==1){ s.erase(l); s.erase(r); ans[r]=')'; if(s.size()==0) break; if((*s.begin())>l){ l=r+1; if(r+1!=N) ans[r+1]='('; r=l+1; }else{ auto it=s.upper_bound(l); it--; l=*it; r=r+1; } } } cout << "!" << " "; rep(i,N) cout << ans[i]; cout << endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...