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 m;
vector<int> eil;
const int dydis = 400000 + 1100;
int state[dydis] = {};
int X[dydis];
int Y[dydis];
int n;
int dbInd = 0;
int closestPower(int a){
for(int i = a+1; i <= a * 2 + 2; i++){
if(__builtin_popcount(i) == 1) return i;
}
return -1;
}
int dfs(int v){
if(v >= n){
int ret = 0;
if(dbInd == (int)eil.size()) {
ret = -1;
}else{
ret = eil[dbInd++];
}
//cout << "dabar " << ret << "\n";
return ret;
}else{
int sk = dfs(v*2 + state[v]);
if(state[v] == 0) X[v-1] = sk;
else Y[v-1] = sk;
state[v] = !state[v];
return -v;
}
}
void create_circuit(int M, vector<int> A) {
eil = A;
vector<int> C(M+1, -1); C[0] = -1;
n = closestPower(A.size());
//cout << "n = " << n << endl;
for(int i = 0; i < n; i++) dfs(1);
vector<int> XX;
for(int i = 0; i < n-1; i++){
XX.push_back(X[i]);
//cout << -(i+1) << " x-as yra " << X[i] << endl;
}
vector<int> YY;
for(int i = 0; i < n-1; i++) {
YY.push_back(Y[i]);
//cout << -i - 1 << " y-as yra " << Y[i] << endl;
}
YY[YY.size()-1] = 0;
// cout << "arciausias " << A.size() << " laipsnis yra " << n << endl;
answer(C, XX, YY);
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... |