#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 |
1 |
Correct |
0 ms |
364 KB |
Output is correct |
2 |
Runtime error |
6 ms |
492 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
364 KB |
Output is correct |
2 |
Correct |
10 ms |
364 KB |
Output is correct |
3 |
Correct |
4 ms |
364 KB |
Output is correct |
4 |
Correct |
8 ms |
364 KB |
Output is correct |
5 |
Correct |
9 ms |
364 KB |
Output is correct |
6 |
Correct |
9 ms |
364 KB |
Output is correct |
7 |
Correct |
8 ms |
364 KB |
Output is correct |
8 |
Correct |
8 ms |
364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Runtime error |
442 ms |
1504 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
846 ms |
1488 KB |
Output is correct |
3 |
Runtime error |
858 ms |
1644 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
4 |
Halted |
0 ms |
0 KB |
- |