Submission #1134134

#TimeUsernameProblemLanguageResultExecution timeMemory
1134134lopkusZagrade (COI20_zagrade)C++20
71 / 100
231 ms1636 KiB
#include <bits/stdc++.h> #define int long long using namespace std; int ask(int l, int r) { cout << "? " << l << " " << r; cout << endl; int x; cin >> x; return x; } signed main() { ios::sync_with_stdio(false); cin.tie(0); int n, q; cin >> n >> q; stack<int> s; s.push(1); vector<int> a(n + 1, - 1); for(int i = 2; i <= n; i++) { if(!s.size()) { s.push(i); continue; } if(ask(s.top(), i)) { a[s.top()] = 1; a[i] = 0; s.pop(); } else { s.push(i); } } cout << "! "; for(int i = 1; i <= n; i++) { if(a[i]) { cout << "("; } else { cout << ")"; } } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...