#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#define fi first
#define se second
#define ll long long
#define pb push_back
#define ii pair<int,int>
const int nax=(1<<16);
int main()
{
int n,q;
cin>>n>>q;
stack<int> st;
st.push(1);
int ans[n+1];
memset(ans,-1,sizeof ans);
for (int i = 2; i <= n; ++i)
{
cout <<"? "<< st.top() << " " << i<<endl;
int c;
cin>>c;
if(c==1){
ans[st.top()]=0;
ans[i]=1;
st.pop();
}else st.push(i);
}
int m=st.size();
for (int i = 0; i < m/2; ++i)
{
ans[st.top()]=0;
st.pop();
}
for (int i = 0; i < m/2; ++i)
{
ans[st.top()]=1;
st.pop();
}
cout << "! ";
for (int i = 1; i <= n; ++i)
{
if(ans[i]==1) cout <<")";
else cout <<"(";
}cout <<endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Runtime error |
1 ms |
344 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
7 ms |
344 KB |
Output is correct |
3 |
Runtime error |
1 ms |
344 KB |
Execution killed with signal 11 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Runtime error |
1 ms |
1108 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
542 ms |
1624 KB |
Output is correct |
3 |
Runtime error |
1 ms |
1108 KB |
Execution killed with signal 11 |
4 |
Halted |
0 ms |
0 KB |
- |