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;
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 < n; i++) {
a[stk[i]] = +1;
}
cout << "! ";
for (int i = 1; i <= n; i++) {
if (a[i] == +1) {
cout << "(";
} else {
cout << ")";
}
}
cout << endl;
}
# | 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... |