이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
// M
#include<bits/stdc++.h>
#include "doll.h"
using namespace std;
const int N = 400005;
int n, m, k, len, ts, need, A[N], L[N], R[N], B[N];
int Solve(int l, int r)
{
if (!need)
return -1;
if (r - l < 2)
{
need --;
return B[l];
}
int v = ++ ts;
R[v] = Solve((l + r) >> 1, r);
L[v] = Solve(l, (l + r) >> 1);
return -v;
}
void create_circuit(int _m, vector < int > _A)
{
m = _m;
n = (int)_A.size();
for (int i = 0; i < n; i ++)
A[i] = _A[i];
A[n] = 0;
if (n == 1)
{
vector < int > C(m + 1, 0);
vector < int > X, Y;
C[0] = A[0];
C[A[0]] = 0;
answer(C, X, Y);
return ;
}
need = n;
while ((1 << k) < n)
k ++;
vector < pair < int , int > > vec;
for (int i = (1 << k) - n; i < (1 << k); i ++)
{
int ra = 0, a = i;
for (int j = 0; j < k; j ++)
ra = (ra << 1) | (a & 1), a >>= 1;
vec.push_back({ra, i});
}
sort(vec.begin(), vec.end());
for (int i = 0; i < n; i ++)
B[vec[i].second] = A[i + 1];
assert(Solve(0, (1 << k)) == -1);
vector < int > C(m + 1, -1);
C[0] = A[0];
vector < int > X(ts), Y(ts);
for (int i = 0; i < ts; i ++)
X[i] = L[i + 1], Y[i] = R[i + 1];
answer(C, X, Y);
return ;
}
# | 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... |