Submission #780952

#TimeUsernameProblemLanguageResultExecution timeMemory
780952devariaotaZagrade (COI20_zagrade)C++17
100 / 100
846 ms1148 KiB
#include<bits/stdc++.h> #define sherina ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define pb push_back #define int long long #define INF 1e18 using namespace std; int n , q; stack < int > st; char ans[200005]; signed main(){ int buka = 0; cin >> n >> q; st.push(1); for(int i = 0 ; i <= n ; i++) ans[i] = '*'; for(int i = 2 ; i <= n ; i++){ if(st.empty()){ st.push(i); continue; } cout << "? " << st.top() << " " << i << endl; int anss; cin >> anss; if(anss){ ans[st.top()] = '('; ans[i] = ')'; buka++; st.pop(); } else st.push(i); } if(st.size() >= 1){ for(int i = 1 ; i <= n ; i++){ if(buka == n / 2) break; if(ans[i] != ')' && ans[i] != '('){ ans[i] = ')'; buka++; } } for(int i = n ; i >= 1 ; i--){ if(ans[i] != ')' && ans[i] != '(') ans[i] = '('; } } 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...