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