Submission #337100

#TimeUsernameProblemLanguageResultExecution timeMemory
337100MrDominoZagrade (COI20_zagrade)C++14
100 / 100
908 ms1496 KiB
#include <bits/stdc++.h> using namespace std; const int N = (int) 1e5 + 7; int n; int q; int a[N]; vector<int> stk; int main() { cin >> n >> q; for (int i = 1; i <= n; i++) { if (stk.empty()) { stk.push_back(i); a[i] = +1; continue; } int j = stk.back(); cout << "? " << j << " " << i << endl; int ret; cin >> ret; if (ret) { stk.pop_back(); a[i] = -1; } else { stk.push_back(i); a[i] = +1; } } int half = (int) stk.size() / 2; for (int i = 0; i < half; i++) { a[stk[i]] = -1; } for (int i = half; i < (int) stk.size(); i++) { a[stk[i]] = +1; } cout << "! "; for (int i = 1; i <= n; i++) { if (a[i] == +1) { cout << "("; } else { cout << ")"; } } 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...