이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "doll.h"
using namespace std;
void create_circuit (int m, vector<int> a) {
int n = a.size();
vector<vector<int>> togo(m+1); vector<int> exit(m+1),x,y;
int lst = 0;
for (int i = 0; i < n; i++) {
togo[lst].push_back(a[i]);
lst = a[i];
}
togo[lst].push_back(0);
for (int j = 0; j <= m; j++) {
if (togo[j].empty()) exit[j] = j;
else if (togo[j].size() == 1) exit[j] = togo[j][0];
else {
int levels = __lg((int)togo[j].size() - 1) + 1, base = (int)x.size();
x.resize(base + (1 << levels) - 1);
y.resize(base + (1 << levels) - 1); vector<int> val(1 << levels); val[1] = 0;
exit[j] = -(base + 1);
for (int i = 1; i < (1 << (levels - 1)); i++) {
x[base + i - 1] = -(base + i * 2);
val[i*2] = val[i];
y[base + i - 1] = -(base + i * 2 + 1);
val[i*2+1] = val[i] | (1 << __lg(i));
}
int lower = (1 << levels) - (int)togo[j].size();
for (int i = (1 << (levels-1)); i < (1 << levels); i++) {
int lVal = val[i], rVal = val[i] | (1 << __lg(i));
if (lVal >= lower) x[base + i - 1] = togo[j][lVal - lower];
else x[base + i - 1] = -(base + 1);
if (rVal >= lower) y[base + i - 1] = togo[j][rVal - lower];
else y[base + i - 1] = -(base + 1);
}
}
}
answer(exit,x,y);
}
# | 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... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |