Submission #781303

#TimeUsernameProblemLanguageResultExecution timeMemory
781303devariaotaZagrade (COI20_zagrade)C++17
100 / 100
744 ms800 KiB
#include<bits/stdc++.h> using namespace std; #define fi first #define se second #define pii pair<int,int> #define pll pair<long long, long long> int n,q,sisa; stack<int> st; char s[100069]; int main() { ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); int i,j; cin>>n>>q; sisa = n/2; for(i=1;i<=n and q;i++) { if(st.empty()) { st.push(i); continue; } cout<<"? "<<st.top()<<" "<<i<<'\n'; cout.flush(); bool valid; cin>>valid; if(valid) { s[st.top()] = '('; s[i] = ')'; sisa--; st.pop(); } else { st.push(i); } q--; } for(j=i;j<=n;j++) st.push(j); while(!st.empty()) { int x = st.top(); st.pop(); if(sisa) { s[x] = '('; sisa--; } else { s[x] = ')'; } } cout<<"! "; for(i=1;i<=n;i++) { cout<<s[i]; if(i == n) { cout<<'\n'; } } // )())(()( }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...