#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
cin.tie(0); ios_base::sync_with_stdio(0);
int n, q;
cin >> n >> q;
vector<int> ans(n, -1), v;
set<int> s;
s.insert(0);
for(int i = 1; i < n; i++) {
int l = *s.rbegin(), r = i;
while(1) {
if(l >= 0 && r < n) {
cout << "? " << l + 1 << " " << r + 1 << endl;
int x; cin >> x;
if(x) {
ans[l] = 1;
ans[r] = 0;
l--, r++;
} else {
break;
}
} else {
break;
}
}
if(ans[i] == -1) s.insert(i);
i = r;
}
cout << "! ";
for(int i = 0; i < n; i++) {
if(ans[i]) cout << '(';
else cout << ')';
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
5 ms |
208 KB |
Output is correct |
3 |
Incorrect |
9 ms |
336 KB |
Mismatch at position 20. Expected ), found ( |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
208 KB |
Mismatch at position 1. Expected ), found ( |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
434 ms |
700 KB |
Output is correct |
3 |
Incorrect |
804 ms |
2848 KB |
Mismatch at position 18. Expected ), found ( |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
208 KB |
Mismatch at position 1. Expected ), found ( |
2 |
Halted |
0 ms |
0 KB |
- |