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 pb push_back
#define x first
#define y second
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
const int inf = 1e9;
int P = 0, SZ = 0;
vector<int> state;
int gen_switch(int N, int &S, vector<int> &X, vector<int> &Y) {
if(N == 1) {SZ++;return inf;}
int L = gen_switch((N + 1) / 2, S, X, Y);
int R = gen_switch((N + 1) / 2, S, X, Y);
int root = --S;
state.pb(0);
X.pb(L), Y.pb(R);
return root;
}
int simulate(int x, vector<int> &A, vector<int> &X, vector<int> &Y) {
if(x == inf) return A[P++];
int pos = -x - 1;
if(state[pos] == 0) X[pos] = simulate(X[pos], A, X, Y);
if(state[pos] == 1) Y[pos] = simulate(Y[pos], A, X, Y);
state[pos] ^= 1;
return x;
}
void create_circuit(int M, vector<int> A) {
A.pb(0);
int S = 0, N = (int)A.size();
vector<int> C, X, Y;
int root = gen_switch(N, S, X, Y);
vector<int> v;
for(int i = N;i < SZ;i++) v.pb(root);
for(int i : A) v.pb(i);
A = v;
N = (int)A.size();
for(int i = 0;i < N;i++) simulate(root, A, X, Y);
C = vector<int>(M + 1, root);
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... |