Submission #986451

#TimeUsernameProblemLanguageResultExecution timeMemory
986451alexddZagrade (COI20_zagrade)C++17
71 / 100
533 ms2108 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=1;i<=cnt;i++) { rez[i]=')'; rez[n-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...