Submission #1111849

#TimeUsernameProblemLanguageResultExecution timeMemory
1111849LM1Zagrade (COI20_zagrade)C++14
100 / 100
1934 ms1592 KiB
#include<bits/stdc++.h> using namespace std; #define ll long long #define pii pair<int,int> #define pb push_back #define ff first #define ss second int main(){ ios_base::sync_with_stdio(NULL);cin.tie(NULL); int n,q,ok;cin>>n>>q; char ans[n+1]; stack<int>st; for(int i=1;i<=n;i++){ if(st.size()==0){ st.push(i); continue; } cout<<"? "<<st.top()<<" "<<i<<endl; cin>>ok; if(ok){ ans[st.top()]='('; ans[i]=')'; st.pop(); } else{ st.push(i); } } int n1=st.size(); for(int i=0;i<n1/2;i++){ ans[st.top()]='('; st.pop(); } while(st.size()){ ans[st.top()]=')'; st.pop(); } cout<<"! "; for(int i=1;i<=n;i++)cout<<ans[i]; 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...