#include<bits/stdc++.h>
#include "doll.h"
using namespace std;
int trie[400001][2] , boss[400001] , here , n , lol;
vector<int> a;
void gettrie( int me , int pw ) {
int ekhane = 1;
for( int z = 0; z < pw ; z++ ) {
if( ((me) & ( 1 << z )) >= 1 ) {
if( trie[ekhane][1] == 1e7 ) {
trie[ekhane][1] = (here);
boss[here] = ekhane;
here++;
}
ekhane = trie[ekhane][1];
}
else{
if( trie[ekhane][0] == 1e7 ) {
trie[ekhane][0] = (here);
boss[here] = ekhane;
here++;
}
ekhane = trie[ekhane][0];
}
}
lol = boss[ekhane];
here--;
if( trie[lol][0] == ekhane ) trie[lol][0] = (-1) * (a[me]);
else trie[lol][1] = (-1) * (a[me]);
}
void create_circuit(int M, vector<int> A) {
a = A;
//a.push_back(0);
int two = 0;
n = a.size();
for( int z = 0; z <= 2 * n; z++ ) {
trie[z][0] = 1e7;
trie[z][1] = 1e7;
}
here = 2;
while( (1 << two) <= n ) two++;
cerr << (1 << two) << " " << n << " lol" << "\n";
for( int z = 1; z < ((1 << two) - n); z++ ) a.push_back(-1);
a.push_back(0);
n = (int)a.size();
for( int z = 0; z < n; z++ ) {
cerr << a[z] << " ";
gettrie(z , two);
}
vector<int> c(M + 1);
vector<int> x(here - 1), y(here - 1);
for( int z = 0; z <= M; z++ ) c[z] = -1;
cerr << here << " " << n << "\n";
for( int z = 1; z < here; z++ ) {
// if( trie[z][0] < -1e8 ) {
x[z - 1] = (trie[z][0] * (-1));
y[z - 1] = (trie[z][1] * (-1));
// }
}
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... |