Submission #1004067

#TimeUsernameProblemLanguageResultExecution timeMemory
1004067vjudge1Zagrade (COI20_zagrade)C++17
100 / 100
606 ms1752 KiB
#include <bits/stdc++.h> using namespace std; int main(){ int n, q; cin >> n >> q; vector<int> vec; vec.push_back(1); char ans[n + 1]; for (int i = 2; i <= n; i ++){ if (vec.size() == 0){ vec.push_back(i); continue; } int l = vec.back(); cout << "? " << l << " " << i << endl; bool regular; cin >> regular; if (regular){ ans[l] = '('; ans[i] = ')'; vec.pop_back(); continue; } vec.push_back(i); } int x = vec.size(); x /= 2; for (int i = 0; i < x; i ++){ int last = vec.back(); ans[last] = '('; vec.pop_back(); } for (int i = 0; i < x; i ++){ int last = vec.back(); ans[last] = ')'; vec.pop_back(); } 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...