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>
#define MAXN (1<<20)
#define MAXM 200010
#define PRINT(x) cerr<<#x<<' '<<x<<endl;
#define pb push_back
using namespace std;
vector<int> X, Y, C;
int x[MAXN], y[MAXN], stdva;
int N, idx;
void ubaci(int node, int put, int kraj, int dub) {
//PRINT(node);
//PRINT(put);
//PRINT(kraj);
//PRINT(dub);
//PRINT(idx);
if(dub == stdva) {
//PRINT(put);
if(put == 0) x[node] = kraj;
if(put == 1) y[node] = kraj;
return;
}
if(!(put&1)) {
if(x[node] == 0) x[node] = --idx;
ubaci(-x[node], put>>1, kraj, dub+1);
} else {
if(y[node] == 0) y[node] = --idx;
ubaci(-y[node], put>>1, kraj, dub+1);
}
}
void create_circuit(int M, std::vector<int> A) {
N = A.size();
C.resize(M+1);
for(int i = 1; i <= M; i++) C[i] = 0;
C[0] = -1;
idx = -1;
for(int i = 0; i < 20; i++) {
if((1<<i) >= N) {
stdva = i;
break;
}
}
for(int i = 0; i < N; i++) {
ubaci(1, i, A[i], 1);
}
idx = -idx;
X.resize(idx);
Y.resize(idx);
for(int i = 1; i <= idx; i++) {
//PRINT(x[i]);
//PRINT(y[i]);
X[i-1] = x[i];
Y[i-1] = y[i];
}
///napisi C[0]
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... |