이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "doll.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<int> C, X, Y, Q[100100];
int l;
vector<int> nxt;
void build_tree(int i, int root, int H, int val, bool on){
if (on && (val&(1<<H))) X[i] = -root;
else if (H){
X.push_back(1e9);
Y.push_back(1e9);
X[i] = -(int)X.size();
build_tree((int)X.size()-1, root, H-1, val, 0);
}
if (H){
X.push_back(1e9);
Y.push_back(1e9);
Y[i] = -(int)X.size();
build_tree((int)X.size()-1, root, H-1, val, on&1);
}
}
bool ON[400400];
void getidx(int i){
ON[i] ^= 1;
if (ON[i]){
if (X[i]==1e9) X[i] = nxt[l++];
else getidx(-X[i]-1);
}
else{
if (Y[i]==1e9) Y[i] = nxt[l++];
else getidx(-Y[i]-1);
}
}
void create_circuit(int M, std::vector<int> A) {
int n = A.size();
C.resize(M+1, -1);
A.push_back(0);
C[0] = A[0];
if (n==1){
fill(C.begin()+1, C.end(), 0);
answer(C, X, Y);
return;
}
X.push_back(1e9); Y.push_back(1e9);
int t = 1, h = 0, R = (int)X.size()-1;
for (;t<n;t<<=1, h++);
build_tree(R, R+1, h-1, t-n, 1);
for (int i=1;i<(int)A.size();i++) nxt.push_back(A[i]);
while(l<(int)nxt.size()) getidx(R);
answer(C, 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... |