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>
#define f first
#define s second
#define pb push_back
#define len(x) x.size()
#define debug(x) cout << #x << " is " << x << endl
using namespace std;
typedef long long ll;
typedef long double ld;
const ll N = 1e6 + 100;
const ll oo = 1e9 + 7;
const ll k = 10;
int main()
{
int n, q;
cin >> n >> q;
stack <int> st;
string ans;
for (int i = 0; i < n; i++)
{
if (st.size() == 0)
{
ans += "(";
st.push(i);
continue;
}
cout << "? " << st.top() + 1 << " " << i + 1 << endl;
bool g;
cin >> g;
if (g)
{
st.pop();
ans += ")";
}
else
{
st.push(i);
ans += "(";
}
}
cout << "! " << ans << endl;
}
# | 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... |