#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(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 |
Incorrect |
7 ms |
320 KB |
Mismatch at position 3. Expected (, found ) |
3 |
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 |
Incorrect |
637 ms |
736 KB |
Mismatch at position 3. Expected (, found ) |
3 |
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 |
- |