이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100005;
int stk[MAXN], top;
int q(int a, int b) {
cout << '?' << ' ' << a << ' ' << b << endl;
int x;
cin >> x;
return x;
}
int main() {
int n, m;
cin >> n >> m;
string s;
for (int i = 1; i <= n; ++i) {
s = s + ' ';
if (top == 0 || !q(stk[top], i)) {
stk[++top] = i;
} else {
s[stk[top--] - 1] = '(';
s[i - 1] = ')';
}
}
for (int i = 1; i <= top / 2; ++i)
s[stk[i] - 1] = ')';
for (int i = top / 2 + 1; i <= top; ++i)
s[stk[i] - 1] = '(';
cout << '!' << ' ' << s;
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... |