#include "doll.h"
#include <bits/stdc++.h>
using namespace std;
const int MAX_M = 1e5;
const int MAX_L = (1 << 18);
int ord[MAX_L];
vector<int> c, x, y;
int switchid( int x ) {
return -(x + 1);
}
vector<int> vert;
vector<pair<int, int>> leafs;
void dfs( int v, int s, int l, bool canCut ) {
vert.push_back( v );
if ( canCut && ((s >> l) & 1) ) {
x[v] = -1;
if ( l == 0 ) {
leafs.push_back( { v, 1 } );
return;
}
dfs( v * 2 + 2, s, l - 1, canCut );
return;
}
if ( l == 0 ) {
leafs.push_back( { v, 0 } );
leafs.push_back( { v, 1 } );
return;
}
dfs( v * 2 + 1, s, l - 1, canCut );
dfs( v * 2 + 2, s, l - 1, false );
}
void create_circuit( int m, vector<int> a ) {
int n = a.size();
c.resize( m + 1 );
a.push_back( 0 );
c[0] = a[0];
int p = ceil( log2( n ) );
x.resize( (1 << p) - 1 );
y.resize( (1 << p) - 1 );
for ( int v = 0; v < (1 << (p - 1)) - 1; v++ ) {
x[v] = switchid( v * 2 + 1 );
y[v] = switchid( v * 2 + 2 );
}
for ( int v = 0; v < (1 << p); v++ ) {
int c = 0;
for ( int b = 0; b < p; b++ ) {
if ((v >> b) & 1 )
c += (1 << (p - 1 - b));
}
ord[c] = v;
}
dfs( 0, (1 << p) - n, p - 1, true );
for ( int i = 1; i <= m; i++ )
c[i] = -1;
for ( auto leaf: leafs ) {
if ( leaf.second == 0 )
x[leaf.first] = 1;
else
y[leaf.first] = 1;
}
y[(1 << p) - 2] = 0;
answer( c, x, y );
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
wrong motion |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
wrong motion |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
wrong motion |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
wrong motion |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
1 ms |
344 KB |
Output is partially correct |
2 |
Correct |
37 ms |
8020 KB |
Output is correct |
3 |
Partially correct |
61 ms |
13008 KB |
Output is partially correct |
4 |
Partially correct |
66 ms |
14728 KB |
Output is partially correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
1 ms |
344 KB |
Output is partially correct |
2 |
Correct |
37 ms |
8020 KB |
Output is correct |
3 |
Partially correct |
61 ms |
13008 KB |
Output is partially correct |
4 |
Partially correct |
66 ms |
14728 KB |
Output is partially correct |
5 |
Incorrect |
80 ms |
15172 KB |
wrong motion |
6 |
Halted |
0 ms |
0 KB |
- |