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>
#include <fstream>
//#define endl '\n'
#define mod 998244353
#define INF 100000000000
#define ll long long
///#define cin fin
///#define cout fout
#define fi first
#define se second
using namespace std;
///ofstream fout("herding.out");
///ifstream fin("herding.in");
int main()
{
ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0);
int n, q; cin >> n >> q; stack<int> st; st.push(1); string s; s.push_back('(');
for(int i = 2; i <= n; i++) {
if(st.empty()) {
st.push(i);
s.push_back('(');
continue;
}
cout << '?' << ' ' << st.top() << ' ' << i << endl;
int ans; cin >> ans;
if(ans == 1) {
st.pop();
s.push_back(')');
}
else {
st.push(i);
s.push_back('(');
}
}
cout << '!' << ' ' << s << 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... |