#include <bits/stdc++.h>
using namespace std;
int ask(int a, int b){
int ans;
cout << "? " << a << " " << b << endl;
cin >> ans;
return ans;
}
int main(){
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int n, t; cin >> n >> t;
stack<int>st;
string ans = "(";
st.push(1);
for(int i = 2; i <= n; i++){
int a = ask(st.top(), i);
if(a){
st.pop();
ans.push_back(')');
} else{
st.push(i);
ans.push_back('(');
}
}
cout << "! " << ans << endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Runtime error |
1 ms |
496 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
208 KB |
Mismatch at position 1. Expected ), found ( |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Runtime error |
1 ms |
448 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
208 KB |
Mismatch at position 1. Expected ), found ( |
2 |
Halted |
0 ms |
0 KB |
- |