This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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(')');
if(st.empty() && i != n){
ans.push_back('(');
st.push(i + 1);
i++;
}
} else{
st.push(i);
ans.push_back('(');
}
}
cout << "! " << ans << endl;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |