#include <bits/stdc++.h>
// #define endl '\n'
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define int ll
typedef long long ll;
using namespace std;
const int N = 200000 + 10;
bool vis[N];
signed main() {
// FAST;
int n, q;
cin >> n >> q;
stack<int> st;
st.push(0);
vis[0] = 1;
for(int i = 1; i < n - 1; i++) {
if(!st.size()) {
st.push(i);
vis[i] = 1;
}
else {
cout << "? " << st.top() + 1 << ' ' << i + 1 << endl;
int x;
cin >> x;
if(x == 1) st.pop();
else {
st.push(i);
vis[i] = 1;
}
}
}
string s = "";
for(int i = 0; i < n; i++) {
if(vis[i]) s += "(";
else s += ")";
}
cout << "! " << s << endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
5 ms |
208 KB |
Output is correct |
3 |
Correct |
10 ms |
304 KB |
Output is correct |
4 |
Correct |
8 ms |
308 KB |
Output is correct |
5 |
Correct |
9 ms |
284 KB |
Output is correct |
6 |
Correct |
10 ms |
292 KB |
Output is correct |
7 |
Correct |
8 ms |
208 KB |
Output is correct |
8 |
Correct |
8 ms |
308 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 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 |
255 ms |
620 KB |
Output is correct |
3 |
Correct |
774 ms |
844 KB |
Output is correct |
4 |
Correct |
820 ms |
780 KB |
Output is correct |
5 |
Correct |
681 ms |
836 KB |
Output is correct |
6 |
Correct |
830 ms |
624 KB |
Output is correct |
7 |
Correct |
756 ms |
756 KB |
Output is correct |
8 |
Correct |
709 ms |
740 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
208 KB |
Mismatch at position 1. Expected ), found ( |
2 |
Halted |
0 ms |
0 KB |
- |