#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;
}
}
cout << "! ";
for (int i = 1; i <= n; i++) {
if (a[i] == +1) {
cout << "(";
} else {
cout << ")";
}
}
cout << endl;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
364 KB |
Output is correct |
2 |
Correct |
4 ms |
364 KB |
Output is correct |
3 |
Correct |
10 ms |
364 KB |
Output is correct |
4 |
Correct |
10 ms |
364 KB |
Output is correct |
5 |
Correct |
10 ms |
364 KB |
Output is correct |
6 |
Correct |
10 ms |
364 KB |
Output is correct |
7 |
Correct |
9 ms |
364 KB |
Output is correct |
8 |
Correct |
7 ms |
364 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
Mismatch at position 1. Expected ), found ( |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
364 KB |
Output is correct |
2 |
Correct |
441 ms |
936 KB |
Output is correct |
3 |
Correct |
748 ms |
600 KB |
Output is correct |
4 |
Correct |
898 ms |
848 KB |
Output is correct |
5 |
Correct |
790 ms |
1096 KB |
Output is correct |
6 |
Correct |
887 ms |
1020 KB |
Output is correct |
7 |
Correct |
976 ms |
1344 KB |
Output is correct |
8 |
Correct |
828 ms |
1004 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
Mismatch at position 1. Expected ), found ( |
2 |
Halted |
0 ms |
0 KB |
- |