This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "doll.h"
#include<bits/stdc++.h>
using namespace std;
vector<int> X, Y;
int oriN;
void fin(int x, int n, int par, bool ok, int val, vector<int> &A, bool flag){
if((x|val) >= n){
if(ok)X[par] = A[x];
else Y[par] = A[x];
}
else{
int no = X.size();
if(!flag){
if(ok)X[par] = -no-1;
else Y[par] = -no-1;
}
X.push_back(0);
Y.push_back(0);
fin(x,n,no,1,val<<1,A,0);
fin(x|val,n,no,0,val<<1,A,0);
}
}
void create_circuit(int m, vector<int> A) {
A.push_back(-1);
int n = A.size();
oriN = n-1;
while((int)A.size() < (1<<(int)ceil(log2(n)))){
A.push_back(-1);
}
A.back() = 0;
n = A.size();
vector<int> C(m + 1,-1);
vector<int> H(m + 1);
fin(0,n,-1,0,1,A,1);
vector<int> nX, nY;
set<int> bad;
for(int i = X.size()-1; i>=0; --i){
if(bad.count(X[i]))X[i] = X[X[i]];
if(bad.count(Y[i]))Y[i] = Y[Y[i]];
if(X[i] == Y[i]){
bad.insert(i);
}
}
vector<int> se;
for(int i = 0; i < (int)X.size(); ++i){
if(bad.count(i))continue;
se.push_back(i+1);
nX.push_back(X[i]);
nY.push_back(Y[i]);
}
vector<int> trans(X.size()+5,0);
for(int i = 0; i < (int)se.size(); ++i){
trans[se[i]] = i+1;
}
for(int i : nX)i = trans[i];
for(int i : nY)i = trans[i];
answer(C, nX, nY);
}
# | 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... |