이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |