Submission #986452

#TimeUsernameProblemLanguageResultExecution timeMemory
986452alexddZagrade (COI20_zagrade)C++17
100 / 100
537 ms2028 KiB
#include<bits/stdc++.h> using namespace std; int n,q; int query(int le, int ri) { if((ri-le+1)%2==1) return 0; cout<<"? "<<le<<" "<<ri<<endl; int aux; cin>>aux; return aux; } char rez[100005]; signed main() { cin>>n>>q; int cnt=n/2; deque<int> dq; for(int i=1;i<=n;i++) { dq.push_back(i); if((int)dq.size()>=2 && query(dq[(int)dq.size()-2],dq.back())) { rez[dq[(int)dq.size()-2]] = '('; rez[dq[(int)dq.size()-1]] = ')'; dq.pop_back(); dq.pop_back(); cnt--; } } for(int i=0;i<cnt;i++) { rez[dq[i]]=')'; rez[dq[(int)dq.size()-i-1]]='('; } cout<<"! "; for(int i=1;i<=n;i++) cout<<rez[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...