#include "doll.h"
#include <bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
using namespace std;
vector<vector<int>> adj;
vector<int> C, X, Y;
int cnt = -1;
void build(int x) {
int n = adj[x].size();
if (n == 1) C[x] = adj[x][0];
else if (n) {
C[x] = cnt; cnt--;
for (int i = n - 1; i > 0; i--) {
Y.pb(0);
int first = cnt + 1;
int time = i - 1;
pair<int,int> act = {0, 0}, pre = {1, cnt + 1};
while (time) {
if (time % pre.fi == 0) {
time -= pre.fi;
Y.pb(pre.se);
X.pb(cnt);
act = {pre.fi, cnt};
pre.fi *= 2;
cnt--;
}
else {
time -= act.fi;
Y.pb(act.se);
X.pb(cnt);
pre = {act.fi * 2, act.se};
act.se = cnt;
cnt--;
}
}
X.pb(adj[x][n - 1 - i]);
auto it = Y.end() + (cnt - first);
if (i != 1) {
*it = cnt;
cnt--;
}
else *it = adj[x].back();
}
}
}
void create_circuit(int M, vector<int> A) {
int N = A.size();
A.push_back(0);
C.resize(M + 1);
adj.resize(M + 1);
adj[0].pb(A[0]); C[0] = A[0];
for (int i = 1; i <= N; i++) adj[A[i-1]].pb(A[i]);
for (int i = 1; i <= M; i++) build(i);
answer(C, X, Y);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
16 ms |
6840 KB |
Output is correct |
3 |
Correct |
15 ms |
5676 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
7 ms |
3932 KB |
Output is correct |
6 |
Correct |
30 ms |
8628 KB |
Output is correct |
7 |
Correct |
0 ms |
344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
16 ms |
6840 KB |
Output is correct |
3 |
Correct |
15 ms |
5676 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
7 ms |
3932 KB |
Output is correct |
6 |
Correct |
30 ms |
8628 KB |
Output is correct |
7 |
Correct |
0 ms |
344 KB |
Output is correct |
8 |
Correct |
31 ms |
9044 KB |
Output is correct |
9 |
Correct |
34 ms |
10056 KB |
Output is correct |
10 |
Correct |
43 ms |
13876 KB |
Output is correct |
11 |
Correct |
0 ms |
344 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
16 ms |
6840 KB |
Output is correct |
3 |
Correct |
15 ms |
5676 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
7 ms |
3932 KB |
Output is correct |
6 |
Correct |
30 ms |
8628 KB |
Output is correct |
7 |
Correct |
0 ms |
344 KB |
Output is correct |
8 |
Correct |
31 ms |
9044 KB |
Output is correct |
9 |
Correct |
34 ms |
10056 KB |
Output is correct |
10 |
Correct |
43 ms |
13876 KB |
Output is correct |
11 |
Correct |
0 ms |
344 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
53 ms |
14896 KB |
Output is correct |
15 |
Incorrect |
42 ms |
10092 KB |
Output isn't correct |
16 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |