Submission #706439

#TimeUsernameProblemLanguageResultExecution timeMemory
706439vjudge1Zagrade (COI20_zagrade)C++14
100 / 100
888 ms1444 KiB
#include<bits/stdc++.h> using namespace std; #define ll long long #define FF first #define SS second #define all(a) a.begin(), a.end() #define mod (ll)(1000000007) bool ask(int l, int r){ int val; cout<<"? "<<l<<' '<<r<<endl; cin>>val; return val; } int main(){ ios_base::sync_with_stdio(0);cin.tie(0); int n, q; cin>>n>>q; int a=n/2,b=n/2; vector<int>Ans(n+1), stk; for(int i=1;i<=n;i++){ if(stk.empty()){ stk.push_back(i); } else{ bool val=ask(stk.back(), i); if(val){ Ans[stk.back()]=1, Ans[i]=2; stk.pop_back(); a--, b--; } else{ stk.push_back(i); } } } cout<<"! "; for(int i=1;i<=n;i++){ char c; if(Ans[i]){ c='('+Ans[i]-1; } else{ if(a) c=')', a--; else c='('; } cout<<c; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...