# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
641595 | gun_gan | Zagrade (COI17_zagrade) | C++17 | 555 ms | 20400 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
cin.tie(0); ios_base::sync_with_stdio(0);
int n, q;
cin >> n >> q;
vector<int> ans(n, -1);
set<int> s;
s.insert(0);
for(int i = 1; i < n; i++) {
if(ans[i] != -1) continue;
while(!s.empty()) {
int l = *s.rbegin(), r = i;
if(l >= 0 && r < n) {
cout << "? " << l + 1 << " " << r + 1 << endl;
int x; cin >> x;
if(x) {
ans[l] = 1;
ans[r] = 0;
s.erase(l);
i++;
} else {
s.insert(r);
break;
}
} else {
break;
}
}
if(s.empty() && ans[i] == -1) s.insert(i);
}
int x = 0;
for(int i = 0; i < n; i++) x += ans[i] == -1;
x /= 2;
while(!s.empty()) s.erase(s.begin());
bool ok = 0;
for(int i = 0; i < n; i++) {
if(ans[i] != -1) continue;
if(s.size() >= x) ok = 1;
if(!ok) s.insert(i);
if(ok) {
ans[*s.rbegin()] = 0;
ans[i] = 1;
s.erase(*s.rbegin());
}
}
cout << "! ";
for(int i = 0; i < n; i++) {
assert(ans[i] != -1);
if(ans[i]) cout << '(';
else cout << ')';
}
}
컴파일 시 표준 에러 (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... |