#include "doll.h"
#include <bits/stdc++.h>
#define eb emplace_back
using namespace std;
const int MAXN = 200055;
int B[MAXN*2][2], C[MAXN*2];
int A[MAXN];
int N, M, K, NP;
int f(int s, int e) {
if(N <= s) return 1;
if(s == e) return -1;
int m = (s+e) >> 1, c = ++K;
B[c][1] = f(s, m);
B[c][0] = f(m+1, e);
return c;
}
void solve() {
N++; for(NP = 2; NP < N; NP <<= 1);
f(0, NP-1);
for(int i = 1, c = 0; c < N;) {
int &j = B[i][C[i]&1]; C[i]++;
if(j < 0) {
j = -A[c++];
i = 1;
continue;
}
i = j;
}
vector<int> CV(M+1, -1), LV, RV;
for(int i = 1; i <= K; i++) {
LV.eb(-B[i][0]);
RV.eb(-B[i][1]);
}
answer(CV, LV, RV);
}
void create_circuit(int M, std::vector<int> A) {
::M = M; ::N = A.size();
for(int i = 0; i < ::N; i++) ::A[i] = A[i];
solve();
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
55 ms |
4532 KB |
Output is correct |
3 |
Correct |
50 ms |
4152 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
12 ms |
1484 KB |
Output is correct |
6 |
Correct |
73 ms |
6364 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
55 ms |
4532 KB |
Output is correct |
3 |
Correct |
50 ms |
4152 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
12 ms |
1484 KB |
Output is correct |
6 |
Correct |
73 ms |
6364 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
97 ms |
7316 KB |
Output is correct |
9 |
Correct |
110 ms |
7700 KB |
Output is correct |
10 |
Correct |
143 ms |
10872 KB |
Output is correct |
11 |
Correct |
1 ms |
204 KB |
Output is correct |
12 |
Correct |
1 ms |
204 KB |
Output is correct |
13 |
Correct |
2 ms |
204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
55 ms |
4532 KB |
Output is correct |
3 |
Correct |
50 ms |
4152 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
12 ms |
1484 KB |
Output is correct |
6 |
Correct |
73 ms |
6364 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
97 ms |
7316 KB |
Output is correct |
9 |
Correct |
110 ms |
7700 KB |
Output is correct |
10 |
Correct |
143 ms |
10872 KB |
Output is correct |
11 |
Correct |
1 ms |
204 KB |
Output is correct |
12 |
Correct |
1 ms |
204 KB |
Output is correct |
13 |
Correct |
2 ms |
204 KB |
Output is correct |
14 |
Correct |
155 ms |
10492 KB |
Output is correct |
15 |
Correct |
93 ms |
6920 KB |
Output is correct |
16 |
Correct |
142 ms |
10288 KB |
Output is correct |
17 |
Correct |
1 ms |
204 KB |
Output is correct |
18 |
Correct |
1 ms |
204 KB |
Output is correct |
19 |
Correct |
1 ms |
204 KB |
Output is correct |
20 |
Correct |
136 ms |
10540 KB |
Output is correct |
21 |
Correct |
1 ms |
204 KB |
Output is correct |
22 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
87 ms |
6444 KB |
Output is correct |
3 |
Correct |
97 ms |
6440 KB |
Output is correct |
4 |
Correct |
129 ms |
9844 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
87 ms |
6444 KB |
Output is correct |
3 |
Correct |
97 ms |
6440 KB |
Output is correct |
4 |
Correct |
129 ms |
9844 KB |
Output is correct |
5 |
Correct |
153 ms |
10108 KB |
Output is correct |
6 |
Correct |
143 ms |
9976 KB |
Output is correct |
7 |
Correct |
132 ms |
10032 KB |
Output is correct |
8 |
Correct |
137 ms |
9972 KB |
Output is correct |
9 |
Correct |
84 ms |
6440 KB |
Output is correct |
10 |
Correct |
135 ms |
9932 KB |
Output is correct |
11 |
Correct |
145 ms |
9752 KB |
Output is correct |
12 |
Correct |
99 ms |
6368 KB |
Output is correct |
13 |
Correct |
91 ms |
6684 KB |
Output is correct |
14 |
Correct |
91 ms |
6812 KB |
Output is correct |
15 |
Correct |
86 ms |
6944 KB |
Output is correct |
16 |
Correct |
3 ms |
460 KB |
Output is correct |
17 |
Correct |
80 ms |
6504 KB |
Output is correct |
18 |
Correct |
94 ms |
6428 KB |
Output is correct |
19 |
Correct |
87 ms |
6360 KB |
Output is correct |
20 |
Correct |
144 ms |
9744 KB |
Output is correct |
21 |
Correct |
139 ms |
9844 KB |
Output is correct |
22 |
Correct |
133 ms |
9816 KB |
Output is correct |