#include "doll.h"
#include<bits/stdc++.h>
using namespace std;
using ll = int;
void create_circuit(int M, std::vector<int> A) {
int N = A.size();
std::vector<int> C(M + 1,0);
C[0] = A[0];
if (N == 1){
for (int i = 1; i <= M; ++i) C[i] = 0;
vector<int> X,Y;
answer(C, X, Y);
return;
}
A.push_back(0);
vector<vector<ll>> nxt(M);
for(ll i = 0;i<N;i++){
nxt[A[i]-1].push_back(A[i+1]);
}
for(auto &o : nxt){
if (o.size()>2) {
ll old = o.back();
o.pop_back();
o.resize(1<<(__lg(o.size())+1),-1);
o.back() = old;
}
}
vector<int> X,Y;
ll it = 0;
vector<ll> CUR;
ll root;
function<ll(ll,ll,ll)> dfs;
dfs = [&](ll cnt, ll st, ll lv){
//cerr << "dfs " << cnt << " " << st << " " << lv << " " << CUR[st] << "\n";
if (cnt==1){
return CUR[st]==-1?root:CUR[st];
}
ll i = it++;
X.emplace_back();
Y.emplace_back();
X[i] = dfs(cnt-cnt/2,st,lv+1);
Y[i] = dfs(cnt/2,st+(1<<lv),lv+1);
return -1-i;
};
for(ll i = 0;i<M;i++){
CUR = nxt[i];
if (CUR.size()>1){
C[i+1] = root = -1-it;
dfs(CUR.size(),0,0);
}else if(CUR.size()==1){
C[i+1] = CUR[0];
}
}
for(ll i = 0;i<N;i++) {
//cerr << "nxt " << i << ":";
//for(ll j : nxt[i]) cerr << " " << j;
//cerr << "\n";
}
answer(C, X, Y);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
25 ms |
6576 KB |
Output is correct |
3 |
Correct |
20 ms |
5328 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
10 ms |
3796 KB |
Output is correct |
6 |
Correct |
31 ms |
7936 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
25 ms |
6576 KB |
Output is correct |
3 |
Correct |
20 ms |
5328 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
10 ms |
3796 KB |
Output is correct |
6 |
Correct |
31 ms |
7936 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
44 ms |
7472 KB |
Output is correct |
9 |
Correct |
50 ms |
8876 KB |
Output is correct |
10 |
Correct |
67 ms |
11700 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
25 ms |
6576 KB |
Output is correct |
3 |
Correct |
20 ms |
5328 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
10 ms |
3796 KB |
Output is correct |
6 |
Correct |
31 ms |
7936 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
44 ms |
7472 KB |
Output is correct |
9 |
Correct |
50 ms |
8876 KB |
Output is correct |
10 |
Correct |
67 ms |
11700 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
84 ms |
11356 KB |
Output is correct |
15 |
Correct |
42 ms |
6216 KB |
Output is correct |
16 |
Correct |
66 ms |
8892 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
1 ms |
212 KB |
Output is correct |
19 |
Correct |
1 ms |
212 KB |
Output is correct |
20 |
Correct |
78 ms |
10832 KB |
Output is correct |
21 |
Correct |
1 ms |
212 KB |
Output is correct |
22 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
1 ms |
212 KB |
Output is partially correct |
2 |
Correct |
40 ms |
7340 KB |
Output is correct |
3 |
Partially correct |
63 ms |
10084 KB |
Output is partially correct |
4 |
Partially correct |
84 ms |
10864 KB |
Output is partially correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
1 ms |
212 KB |
Output is partially correct |
2 |
Correct |
40 ms |
7340 KB |
Output is correct |
3 |
Partially correct |
63 ms |
10084 KB |
Output is partially correct |
4 |
Partially correct |
84 ms |
10864 KB |
Output is partially correct |
5 |
Partially correct |
93 ms |
12540 KB |
Output is partially correct |
6 |
Partially correct |
105 ms |
13104 KB |
Output is partially correct |
7 |
Partially correct |
99 ms |
12936 KB |
Output is partially correct |
8 |
Partially correct |
102 ms |
13332 KB |
Output is partially correct |
9 |
Partially correct |
65 ms |
10388 KB |
Output is partially correct |
10 |
Partially correct |
98 ms |
14900 KB |
Output is partially correct |
11 |
Partially correct |
99 ms |
14812 KB |
Output is partially correct |
12 |
Partially correct |
62 ms |
9756 KB |
Output is partially correct |
13 |
Partially correct |
63 ms |
8788 KB |
Output is partially correct |
14 |
Partially correct |
63 ms |
8604 KB |
Output is partially correct |
15 |
Partially correct |
66 ms |
8456 KB |
Output is partially correct |
16 |
Partially correct |
2 ms |
596 KB |
Output is partially correct |
17 |
Partially correct |
53 ms |
7592 KB |
Output is partially correct |
18 |
Partially correct |
58 ms |
7676 KB |
Output is partially correct |
19 |
Partially correct |
61 ms |
8052 KB |
Output is partially correct |
20 |
Partially correct |
88 ms |
10340 KB |
Output is partially correct |
21 |
Partially correct |
98 ms |
12164 KB |
Output is partially correct |
22 |
Partially correct |
70 ms |
9804 KB |
Output is partially correct |