#include "doll.h"
#include <bits/stdc++.h>
#define MAXN (1<<20)
#define MAXM 200010
#define PRINT(x) cerr<<#x<<' '<<x<<endl;
#define pb push_back
using namespace std;
vector<int> X, Y, C;
int x[MAXN], y[MAXN], stdva;
int N, idx;
void ubaci(int node, int put, int kraj, int dub) {
//PRINT(node);
if(dub == stdva) {
if(put == 0) x[node] = kraj;
if(put == 1) y[node] = kraj;
return;
}
if(!(put&1)) {
if(x[node] == -1) x[node] = --idx;
ubaci(-x[node], put>>1, kraj, dub+1);
} else {
if(y[node] == -1) y[node] = --idx;
ubaci(-y[node], put>>1, kraj, dub+1);
}
}
void nadji(int node) {
if(y[node] == -1) {
y[node] = 0;
return;
}
nadji(-y[node]);
}
void create_circuit(int M, std::vector<int> A) {
N = A.size();
C.resize(M+1);
for(int i = 1; i <= M; i++) C[i] = -1;
C[0] = -1;
idx = -1;
for(int i = 0; i < 20; i++) {
if((1<<i) > N) {
stdva = i;
break;
}
}
fill(x, x+MAXN, -1);
fill(y, y+MAXN, -1);
for(int i = 0; i < N; i++) {
ubaci(1, i, A[i], 1);
}
ubaci(1, (1<<stdva)-1, 0, 1);
//nadji(1);
idx = -idx;
X.resize(idx);
Y.resize(idx);
//if((1<<stdva) == N)
//PRINT(idx);
//C[A[N-1]] = 0;
for(int i = 1; i <= idx; i++) {
//PRINT(x[i]);
//PRINT(y[i]);
X[i-1] = x[i];
Y[i-1] = y[i];
}
answer(C, X, Y);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
8396 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
8396 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
8396 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
8396 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
6 ms |
8396 KB |
Output is partially correct |
2 |
Partially correct |
90 ms |
15684 KB |
Output is partially correct |
3 |
Partially correct |
105 ms |
15768 KB |
Output is partially correct |
4 |
Partially correct |
114 ms |
16196 KB |
Output is partially correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
6 ms |
8396 KB |
Output is partially correct |
2 |
Partially correct |
90 ms |
15684 KB |
Output is partially correct |
3 |
Partially correct |
105 ms |
15768 KB |
Output is partially correct |
4 |
Partially correct |
114 ms |
16196 KB |
Output is partially correct |
5 |
Partially correct |
110 ms |
17152 KB |
Output is partially correct |
6 |
Partially correct |
107 ms |
16932 KB |
Output is partially correct |
7 |
Partially correct |
118 ms |
17056 KB |
Output is partially correct |
8 |
Partially correct |
106 ms |
16672 KB |
Output is partially correct |
9 |
Partially correct |
83 ms |
15684 KB |
Output is partially correct |
10 |
Partially correct |
104 ms |
16792 KB |
Output is partially correct |
11 |
Partially correct |
109 ms |
16320 KB |
Output is partially correct |
12 |
Partially correct |
87 ms |
15928 KB |
Output is partially correct |
13 |
Partially correct |
92 ms |
16424 KB |
Output is partially correct |
14 |
Partially correct |
90 ms |
16488 KB |
Output is partially correct |
15 |
Partially correct |
92 ms |
16568 KB |
Output is partially correct |
16 |
Partially correct |
9 ms |
8780 KB |
Output is partially correct |
17 |
Correct |
61 ms |
12608 KB |
Output is correct |
18 |
Partially correct |
100 ms |
15912 KB |
Output is partially correct |
19 |
Partially correct |
92 ms |
15964 KB |
Output is partially correct |
20 |
Partially correct |
107 ms |
16484 KB |
Output is partially correct |
21 |
Partially correct |
109 ms |
16288 KB |
Output is partially correct |
22 |
Partially correct |
118 ms |
16316 KB |
Output is partially correct |