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;
int n;
int maxProf;
vector<int> X, Y, V;
int create();
int tree(int prof, int val, bool flag);
void create_circuit(int M, vector<int> A) {
n = A.size();
maxProf = log2(n + 1);
if(__builtin_popcount(n + 1) != 1) maxProf++;
vector<int> C (M + 1, -1);
V = A;
tree(0, 0, 1);
// for(int i = 0; i < X.size(); i++){
// printf("%d %d\n", -i - 1, X[i]);
// printf("%d %d\n", -i - 1, Y[i]);
// }
answer(C, X, Y);
}
int create(){
X.push_back(0);
Y.push_back(0);
return X.size() - 1;
}
int tree(int prof, int val, bool flag){
if(val >= n && !flag) return -1;
if(prof == maxProf){
if(flag) return 0;
return V[val];
}
int cur = create();
int eVal = val, dVal = val + (1 << prof);
int e = tree(prof + 1, eVal, 0);
X[cur] = e;
int d = tree(prof + 1, dVal, flag);
Y[cur] = d;
return -cur - 1;
}
# | 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... |