#include <bits/stdc++.h>
using namespace std;
bool guess(int a, int b) {
cout << "? " << a << ' ' << b << endl;
bool res;
cin >> res;
return res;
}
int main() {
int n, q;
cin >> n >> q;
stack<int> stck;
string ans = "! ";
for (int i = 1; i <= n; i++) {
if (!stck.size()) {
ans += "(";
stck.push(i);
} else {
if (guess(stck.top(), i)) {
stck.pop();
ans += ")";
} else {
stck.push(i);
ans += "(";
}
}
}
cout << ans << endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
5 ms |
364 KB |
Output is correct |
3 |
Correct |
8 ms |
364 KB |
Output is correct |
4 |
Correct |
8 ms |
364 KB |
Output is correct |
5 |
Correct |
7 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 |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
501 ms |
744 KB |
Output is correct |
3 |
Correct |
948 ms |
692 KB |
Output is correct |
4 |
Correct |
926 ms |
908 KB |
Output is correct |
5 |
Correct |
966 ms |
680 KB |
Output is correct |
6 |
Correct |
884 ms |
944 KB |
Output is correct |
7 |
Correct |
900 ms |
1036 KB |
Output is correct |
8 |
Correct |
897 ms |
756 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
Mismatch at position 1. Expected ), found ( |
2 |
Halted |
0 ms |
0 KB |
- |