# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
566658 | two_sides | 도서관 (JOI18_library) | C++17 | 38 ms | 208 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "library.h"
namespace {
using namespace std;
const int N = 1005;
int nxt[N][2];
void add_edge(int i, int j) {
if (nxt[i][0]) nxt[i][1] = j;
else nxt[i][0] = j;
if (nxt[j][0]) nxt[j][1] = i;
else nxt[j][0] = i;
}
}
void Solve(int n) {
for (int i = 1; i <= n; i++) {
vector<int> p;
if (nxt[i][1]) continue;
for (int j = 1; j <= n; j++)
if (j != i && j != nxt[i][0])
p.push_back(j);
int lo = 0, hi = p.size();
while (lo < hi) {
int mi = (lo + hi) / 2;
vector<int> q(n);
for (int j = 0; j <= mi; j++)
q[p[j] - 1] = 1;
int tmp = Query(q); q[i - 1] = 1;
if (Query(q) > tmp) lo = mi + 1;
else hi = mi;
}
if (hi < p.size()) add_edge(i, p[hi]);
}
vector<int> ans(1, 1);
while (nxt[ans[0]][1]) ans[0]++;
for (int i = 0; i + 1 < n; i++) {
if (i == 0 || nxt[ans[i]][0] != ans[i - 1])
ans.push_back(nxt[ans[i]][0]);
else ans.push_back(nxt[ans[i]][1]);
}
Answer(ans);
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |