Submission #1003900

#TimeUsernameProblemLanguageResultExecution timeMemory
1003900vjudge1Zagrade (COI20_zagrade)C++17
0 / 100
602 ms1960 KiB
#include<bits/stdc++.h> using namespace std; #define int long long #define pb push_back #define pii pair<int,int> #define tii tuple<int,int,int,int,int> #define all(x) x.begin(),x.end() #define allr(x) x.rbegin(),x.rend() bool ask(int l, int r){ cout << "? " << l << " " << r << endl; int rt; cin >> rt; return rt; } signed main(){ int n,q; cin >> n >> q; vector<bool> small(n+5,0); for(int i=1; i<n; i++){ small[i] = ask(i,i+1); } vector<int> p(n+5,0), s(n+5,0); for(int i=1; i<=n; i++){ p[i] = p[i-1]+1-small[i-1]; } for(int i=n; i>0; i--){ s[i] = s[i+1]+1-small[i]; } int bp=-1; for(int i=1; i<n; i++){ if(p[i]==s[i+1]){ bp=i; break; } } assert(bp!=-1); cout << "! "; for(int i=1; i<=n; i++){ if(small[i]) cout << "()", i++; else{ if(i<=bp) cout << "("; else cout << ")"; } } cout << endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...