#include <bits/stdc++.h>
using namespace std;
int main() {
int n, q; cin >> n >> q;
int ans[n];
//suppose this is a valid bracket sequence.
for (int j = 0; j < n; j++) {
int started = 0;
for (int i = j+1; i <= n-1; i += 2) {
cout << "? " << ' ' << j+1 << ' ' << i+1 << '\n';
int x; cin >> x;
if (x == 1) {started = 1; break;}
}
if (started) ans[j] = 0;
else ans[j] = 1;
}
cout << "! ";
for (int i = 0; i < n; i++) {
if (ans[i] == 0) cout << '(';
else cout << ')';
}
}
# | 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... |