#include <bits/stdc++.h>
using namespace std;
int marc[100005];
stack<int> st;
int main(){
int n,q; cin>>n>>q;
st.push(1); marc[1] = 1;
for(int i = 2; i <= n; i++){
cout<<"? "<<st.top()<<" "<<i<<endl;
int x; cin>>x;
if(x == 0){
marc[i] = 1;
st.push(i);
}else{
marc[i] = 0;
st.pop();
}
}
cout<<"! ";
for(int i = 1; i <= n; i++){
if(marc[i] == 0)cout<<")";
else cout<<"(";
}cout<<endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Runtime error |
0 ms |
344 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Mismatch at position 1. Expected ), found ( |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Runtime error |
0 ms |
344 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Mismatch at position 1. Expected ), found ( |
2 |
Halted |
0 ms |
0 KB |
- |