Submission #1003765

#TimeUsernameProblemLanguageResultExecution timeMemory
1003765vjudge1Zagrade (COI20_zagrade)C++17
100 / 100
579 ms2184 KiB
#include <bits/stdc++.h> using namespace std; #define fi first #define se second #define pb push_back #define all(x) x.begin(), x.end() #define allr(x) x.rbegin(), x.rend() #define mp make_pair typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef complex<double> cd; const int MAXN = 1e5+10; const int MOD = 1e9+7; const int INF = 0x3f3f3f3f; const ll LINF = 0x3f3f3f3f3f3f3f3f; const double PI = acos(-1); void solve(){ int n, q; cin >> n >> q; stack<int> last; int curr=1; string res; int val=0; vector<int> skip(n, 0); while(curr<=n){ if(last.empty()){ res+='('; last.push(curr); curr++; continue; } cout << "? " << last.top() << " " << curr << endl; int aux; cin >> aux; if(aux){ skip[last.top()-1]=1; skip[curr-1]=1; last.pop(); res+=')'; val++; } else{ last.push(curr); res+='('; } curr++; } for(int i=0;i<n && val<(n>>1);i++){ if(skip[i]) continue; res[i]=')'; val++; } cout << "! " << res << endl; } int32_t main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); int tt=1; //~ cin >> tt; while(tt--) solve(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...