#include <bits/stdc++.h>
using namespace std;
string ans = "(";
int query(int a, int b){
cout << "? " << a+1 << " " << b+1 << endl;
int x; cin >> x;
return x;
}
int main(){
cin.tie(0)->sync_with_stdio(false);
int n, q; cin >> n >> q;
vector<int> pos; pos.push_back(0);
for(int i = 1; i<n; i++)
if(pos.empty() || !query(pos.back(), i))
pos.push_back(i), ans += '(';
else ans += ')';
for(int i = 0; i<(int)pos.size()/2; i++)
ans[pos[i]] = ')';
cout << "! " << ans << endl;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Output is correct |
2 |
Incorrect |
13 ms |
308 KB |
Mismatch at position 1. Expected (, found ) |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Output is correct |
2 |
Correct |
9 ms |
308 KB |
Output is correct |
3 |
Incorrect |
12 ms |
312 KB |
Mismatch at position 1. Expected (, found ) |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
200 KB |
Mismatch at position 1. Expected (, found ) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Output is correct |
2 |
Correct |
972 ms |
1096 KB |
Output is correct |
3 |
Incorrect |
947 ms |
1128 KB |
Mismatch at position 1. Expected (, found ) |
4 |
Halted |
0 ms |
0 KB |
- |