#include "doll.h"
#include<cstdio>
#include<algorithm>
#include<queue>
#define N_ 401000
using namespace std;
int n, m, Out[N_], cnt, chk[N_*10], PV;
int RR[N_ * 10][2];
vector<int>E[N_], TP;
void Go(int a, int L, int cur, int ed) {
if (L == 1) {
if (RR[a][cur & 1]) {
RR[RR[a][cur & 1]][0] = ed;
return;
}
RR[a][cur & 1] = ed;
return;
}
if (!RR[a][cur & 1])RR[a][cur & 1] = ++cnt;
Go(RR[a][cur & 1], L - 1, cur >> 1, ed);
}
int Make() {
int ret = cnt + 1;
int i, sz = 1, cc = 0, j;
int L = TP.size();
while (sz < L) sz *= 2, cc++;
for (i = 1; i < sz/2; i++) {
RR[cnt + i][0] = cnt + i * 2;
RR[cnt + i][1] = cnt + i * 2 + 1;
}
cnt += sz - 1;
for (i = 0; i < L; i++) {
Go(ret, cc, sz - L + i, -TP[i]);
}
for (i = ret; i <= cnt; i++) {
if (!RR[i][0])RR[i][0] = ret;
}
return -ret;
}
void create_circuit(int M, std::vector<int> A) {
n = A.size();
m = M;
E[0].push_back(A[0]);
int i;
for (i = 0; i < n - 1; i++) {
E[A[i]].push_back(A[i + 1]);
}
E[A[n - 1]].push_back(0);
for (i = 0; i <= M; i++) {
if (E[i].size() == 0) Out[i] = 0;
else if (E[i].size() == 1)Out[i] = E[i][0];
else {
TP = E[i];
Out[i] = Make();
}
}
vector<int>C(m+1), X(cnt), Y(cnt);
for (i = 0; i <= m; i++)C[i] = Out[i];
for (i = 0; i < cnt; i++)X[i] = -RR[i+1][0], Y[i] = -RR[i+1][1];
answer(C, X, Y);
}
Compilation message
doll.cpp: In function 'int Make()':
doll.cpp:29:25: warning: unused variable 'j' [-Wunused-variable]
29 | int i, sz = 1, cc = 0, j;
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9 ms |
9676 KB |
Output is correct |
2 |
Correct |
52 ms |
13836 KB |
Output is correct |
3 |
Correct |
32 ms |
13288 KB |
Output is correct |
4 |
Correct |
8 ms |
9624 KB |
Output is correct |
5 |
Correct |
18 ms |
11212 KB |
Output is correct |
6 |
Correct |
46 ms |
15116 KB |
Output is correct |
7 |
Correct |
9 ms |
9676 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9 ms |
9676 KB |
Output is correct |
2 |
Correct |
52 ms |
13836 KB |
Output is correct |
3 |
Correct |
32 ms |
13288 KB |
Output is correct |
4 |
Correct |
8 ms |
9624 KB |
Output is correct |
5 |
Correct |
18 ms |
11212 KB |
Output is correct |
6 |
Correct |
46 ms |
15116 KB |
Output is correct |
7 |
Correct |
9 ms |
9676 KB |
Output is correct |
8 |
Correct |
68 ms |
15852 KB |
Output is correct |
9 |
Correct |
79 ms |
16364 KB |
Output is correct |
10 |
Correct |
95 ms |
19068 KB |
Output is correct |
11 |
Correct |
7 ms |
9660 KB |
Output is correct |
12 |
Correct |
9 ms |
9704 KB |
Output is correct |
13 |
Correct |
10 ms |
9676 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9 ms |
9676 KB |
Output is correct |
2 |
Correct |
52 ms |
13836 KB |
Output is correct |
3 |
Correct |
32 ms |
13288 KB |
Output is correct |
4 |
Correct |
8 ms |
9624 KB |
Output is correct |
5 |
Correct |
18 ms |
11212 KB |
Output is correct |
6 |
Correct |
46 ms |
15116 KB |
Output is correct |
7 |
Correct |
9 ms |
9676 KB |
Output is correct |
8 |
Correct |
68 ms |
15852 KB |
Output is correct |
9 |
Correct |
79 ms |
16364 KB |
Output is correct |
10 |
Correct |
95 ms |
19068 KB |
Output is correct |
11 |
Correct |
7 ms |
9660 KB |
Output is correct |
12 |
Correct |
9 ms |
9704 KB |
Output is correct |
13 |
Correct |
10 ms |
9676 KB |
Output is correct |
14 |
Correct |
114 ms |
20596 KB |
Output is correct |
15 |
Correct |
67 ms |
15260 KB |
Output is correct |
16 |
Correct |
121 ms |
18204 KB |
Output is correct |
17 |
Correct |
9 ms |
9676 KB |
Output is correct |
18 |
Correct |
7 ms |
9600 KB |
Output is correct |
19 |
Correct |
8 ms |
9676 KB |
Output is correct |
20 |
Correct |
148 ms |
19660 KB |
Output is correct |
21 |
Correct |
7 ms |
9704 KB |
Output is correct |
22 |
Correct |
7 ms |
9676 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
9 ms |
9676 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
7 ms |
9676 KB |
Output is partially correct |
2 |
Correct |
79 ms |
15992 KB |
Output is correct |
3 |
Partially correct |
106 ms |
19940 KB |
Output is partially correct |
4 |
Partially correct |
128 ms |
21216 KB |
Output is partially correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
7 ms |
9676 KB |
Output is partially correct |
2 |
Correct |
79 ms |
15992 KB |
Output is correct |
3 |
Partially correct |
106 ms |
19940 KB |
Output is partially correct |
4 |
Partially correct |
128 ms |
21216 KB |
Output is partially correct |
5 |
Partially correct |
130 ms |
22892 KB |
Output is partially correct |
6 |
Partially correct |
150 ms |
24040 KB |
Output is partially correct |
7 |
Partially correct |
156 ms |
23564 KB |
Output is partially correct |
8 |
Partially correct |
142 ms |
24788 KB |
Output is partially correct |
9 |
Partially correct |
109 ms |
19712 KB |
Output is partially correct |
10 |
Partially correct |
190 ms |
24620 KB |
Output is partially correct |
11 |
Partially correct |
141 ms |
25464 KB |
Output is partially correct |
12 |
Partially correct |
98 ms |
20076 KB |
Output is partially correct |
13 |
Partially correct |
99 ms |
19192 KB |
Output is partially correct |
14 |
Partially correct |
87 ms |
18752 KB |
Output is partially correct |
15 |
Partially correct |
89 ms |
18400 KB |
Output is partially correct |
16 |
Partially correct |
13 ms |
9988 KB |
Output is partially correct |
17 |
Partially correct |
97 ms |
17892 KB |
Output is partially correct |
18 |
Partially correct |
94 ms |
17996 KB |
Output is partially correct |
19 |
Partially correct |
92 ms |
18544 KB |
Output is partially correct |
20 |
Partially correct |
138 ms |
20972 KB |
Output is partially correct |
21 |
Partially correct |
115 ms |
23368 KB |
Output is partially correct |
22 |
Partially correct |
119 ms |
20344 KB |
Output is partially correct |