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;
const int N = 1e6;
vector<int> x(N), y(N), c(N);
vector<int> state(N);
int nodecnt=0, n, pw=1;
int build(int l, int r) {
if(l >= r)return 0;
if(r < pw - n) {
return -1;
}
int mid = (l+r)/2;
int cur = ++nodecnt;
x[cur-1] = build(l, mid);
y[cur-1] = build(mid+1, r);
return -cur;
}
void ins(int i, int val) {
if(state[-i]) {
state[-i]^=1;
if(y[-i-1] == 0) {
y[-i-1] = val;
}
else {
ins(y[-i-1], val);
}
}
else {
state[-i]^=1;
if(x[-i-1] == 0) {
x[-i-1] = val;
}
else {
ins(x[-i-1], val);
}
}
}
void create_circuit(int M, std::vector<int> A) {
pw = 1;
n = A.size();
c=vector<int>(M+1, -1);
while(pw < n) {
pw*=2;
}
build(0, pw-1);
for(int i = 1;i<n;i++) {
ins(-1, A[i]);
}
if(n%2 == 1)ins(-1,-1);
ins(-1,0);
c[0] = A[0];
while(x.size()>nodecnt)x.pop_back();
while(y.size()>nodecnt)y.pop_back();
answer(c, x, y);
}
Compilation message (stderr)
doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:53:16: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
53 | while(x.size()>nodecnt)x.pop_back();
| ~~~~~~~~^~~~~~~~
doll.cpp:54:16: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
54 | while(y.size()>nodecnt)y.pop_back();
| ~~~~~~~~^~~~~~~~
# | 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... |