#include <bits/stdc++.h>
using namespace std;
int n, q, odg;
stack<int> s;
char sol[100005];
int main () {
ios_base::sync_with_stdio(false);
cin.tie(0);
cin >> n >> q;
for (int i = 1; i <= n; i++) {
if (s.size() == 0) {
s.push(i);
continue;
}
cout << "? " << s.top() << " " << i << endl;
cin >> odg;
if (odg == 0) {
s.push(i);
}
else {
sol[s.top()] = '(';
sol[i] = ')';
s.pop();
}
}
int kol = (int)s.size()/2;
while ((int)s.size() > kol) {
sol[s.top()] = '(';
s.pop();
}
while ((int)s.size() > 0) {
sol[s.top()] = ')';
s.pop();
}
for (int i = 1; i <= n; i++) cout << sol[i];
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
208 KB |
Incorrect query () |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
208 KB |
Incorrect query )( |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
208 KB |
Incorrect query (()) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
208 KB |
Incorrect query ))(( |
2 |
Halted |
0 ms |
0 KB |
- |