# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
373613 | wind_reaper | Zagrade (COI20_zagrade) | C++17 | 1 ms | 384 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n, q;
cin >> n >> q;
vector<char> ans(n, '.');
vector<int> stack;
for(int i = 0; i < n; i++){
if(stack.empty()){
stack.push_back(i);
continue;
}
cout << stack.back() + 1 << ' ' << i + 1 << endl;
bool v;
cin >> v;
if(v){
ans[stack.back()] = '(', ans[i] = ')';
stack.pop_back();
}
else stack.push_back(i);
}
for(int i = 0; i < stack.size() / 2; i++)
ans[i] = ')';
for(int i = stack.size()/2; i < stack.size(); i++)
ans[i] = '(';
cout << "! ";
for(int i = 0; i < n; i++)
cout << ans[i];
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |