Submission #706433

#TimeUsernameProblemLanguageResultExecution timeMemory
706433vjudge1Zagrade (COI20_zagrade)C++17
100 / 100
867 ms1316 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define int long long //#define endl '\n' #define all(a) a.begin(),a.end() #define pii pair<int,int> #define F first #define S second #define sz(x) (int)(x).size() #define pb push_back const int mod = 1e7 + 7; const int N = 1e6 + 15; const ll inf = 1e18; int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); stack<int> st; st.push(0); int n,q; cin >> n >> q; vector<char> a(n,'x'); int valid=0; int op=n/2,cl=n/2; // number of open bracket needed .. for (int i=1;i<n;i++){ if (st.empty()){ st.push(i); continue; } cout << "? " << st.top()+1 << ' ' << i+1 << endl; cout.flush(); cin >> valid; if (valid){ a[st.top()] = '('; a[i] = ')'; op--;cl--; st.pop(); } else { st.push(i); } } // now they are )))((( for (int i=0;i<op;i++){ a[st.top()] = '('; st.pop(); } for (int i=0;i<cl;i++){ a[st.top()] = ')'; st.pop(); } cout << "! "; for (auto it : a) cout << it ; cout << endl; cout.flush(); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...