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 marc[100005];
stack<int> st;
int main(){
int n,q; cin>>n>>q;
for(int i = 1; i <= n; i++){
if(st.size() == 0){
marc[i] = 1;
st.push(i);
continue;
}
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;
}
# | 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... |