# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
706365 | vjudge1 | Zagrade (COI20_zagrade) | C++17 | 854 ms | 1420 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define int long long
// #define endl '\n'
const int M = 4e5+5, MOD = 998244353;
char s[M];
signed main() {
cin.tie(0)->sync_with_stdio(0);
int n, q;
cin >> n >> q;
int cnt = n/2;
stack<int> st;
for (int i = 1; i <= n; i++) {
if (!st.size()) st.push(i);
else {
cout << "? " << st.top() << ' ' << i << endl;
int x;
cin >> x;
if (x) cnt--, s[i]=')', s[st.top()] = '(', st.pop();
else st.push(i);
}
}
cout << "! ";
for (int i = 1; i <= n; i++)
if (!s[i]) cnt?s[i]=')', cnt--:s[i]='(';
for (int i = 1; i <= n; i++) cout << s[i]; cout << endl;
return 0;
}
/*
1234567890123456
))(()(())()(()()
)))()(())())()()
16 0 0 0 0 1 0 0 1 1 0 1 0 0 1 0 1
*/
컴파일 시 표준 에러 (stderr) 메시지
# | 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... |