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 eb emplace_back
#define printv(a, b) { \
for(auto pv : a) b << pv << " "; \
b << "\n"; \
}
using namespace std;
int n, m;
vector<int> a;
vector<int> x, y;
int s;
vector<bool> state;
int go = 0;
int dfs(int now){
if(now == 0) return go;
if(!state[now - 1]){
state[now - 1] = true;
x[now - 1] = dfs(-x[now - 1]);
}
else{
state[now - 1] = false;
y[now - 1] = dfs(-y[now - 1]);
}
return -now;
}
void create_circuit(int _m, vector<int> _a){
m = _m;
a = _a;
n = a.size();
int leaf = 1;
int s = 1;
while(leaf * 2 < n){
leaf *= 2;
s += leaf;
}
x.resize(s);
y.resize(s);
for(int i = 1; i <= s; i++){
if(2 * i <= s) x[i - 1] = - (2 * i);
if(2 * i + 1 <= s) y[i - 1] = - (2 * i + 1);
}
//cerr << leaf * 2 << "\n";
//printv(x, cerr);
//printv(y, cerr);
vector<int> c(m + 1, -1);
state.resize(s);
c[0] = a[0];
for(int i = 0; i < n - 1; i++){
go = a[i + 1];
dfs(1);
}
for(int i = n - 1; i < leaf * 2 - 1; i++){
go = -1;
dfs(1);
//cerr << "temp\n";
}
go = 0;
dfs(1);
//printv(x, cerr);
//printv(y, cerr);
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... |