#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
//#define endl '\n'
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define F first
#define S second
#define sz(x) (int)(x).size()
#define pb push_back
const int mod = 1e7 + 7;
const int N = 1e6 + 15;
const ll inf = 1e18;
int32_t main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
stack<int> st;
st.push(0);
int n,q;
cin >> n >> q;
vector<char> a(n,'x');
bool valid;
int op=n/2,cl=n/2; // number of open bracket needed ..
for (int i=1;i<n;i++){
cout << "? " << st.top() << ' ' << i << endl;
cin >> valid;
if (valid){
a[st.top()] = '(';
a[i] = ')';
op--;cl--;
st.pop();
}
else {
st.push(i);
}
}
// now they are )))(((
for (int i=0;i<op;i++){
a[st.top()] = '(';
st.pop();
}
for (int i=0;i<cl;i++){
a[st.top()] = ')';
st.pop();
}
cout << "! "; for (auto it : a) cout << it ;
cout << endl;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
208 KB |
Execution killed with signal 13 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
0 ms |
208 KB |
Execution killed with signal 13 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
208 KB |
Execution killed with signal 13 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
208 KB |
Execution killed with signal 13 |
2 |
Halted |
0 ms |
0 KB |
- |