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;
typedef long long ll;
int main()
{
cin.tie(0); ios_base::sync_with_stdio(0);
int n, q;
cin >> n >> q;
vector<int> ans(n, -1);
for(int i = 0; i < n - 1; i++) {
cout << "? " << i + 1 << " " << i + 2 << endl;
int x; cin >> x;
if(x) {
ans[i] = 1;
ans[i + 1] = 0;
i++;
}
}
cout << "! ";
for(int i = 0; i < n; i++) {
if(ans[i] == -1) {
int cnt = 0;
int j = i;
for(; ans[j] == -1; j++) {
ans[j] = 1;
cnt++;
}
while(ans[j] != -1) j++;
for(; cnt > 0; j++, cnt--) {
ans[j] = 0;
}
}
cout << (ans[i] ? '(' : ')');
}
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... |