#include <bits/stdc++.h>
#include "doll.h"
using namespace std;
int N, cnter = 0;
vector<int> adj[100001];
vector<int> X(400002), Y(400002);
vector<int> C(200002);
void build(int a, int cur, int l, int r){
if(l == r){
X[abs(cur)] = cur;
Y[abs(cur)] = l;
return;
}
if(l == r - 1){
X[abs(cur)] = adj[a][l];
Y[abs(cur)] = adj[a][r];
return;
}
int mid = (l + r) >> 1;
X[abs(cur)] = --cnter;
build(a, cnter, l, mid);
Y[abs(cur)] = --cnter;
build(a, cnter, mid + 1, r);
}
void create_circuit(int M, vector<int> A) {
N = A.size();
for(int i = 0; i < N - 1; i++) adj[A[i]].push_back(A[i + 1]);
adj[A[N - 1]].push_back(0);
C[0] = A[0];
for(int i = 1; i <= M; i++){
if(adj[i].size() == 0) continue;
if(adj[i].size() == 1) C[i] = adj[i][0];
else{
C[i] = --cnter;
build(i, cnter, 0, adj[i].size() - 1);
}
}
vector<int> CA, XA, YA;
for(int i = 1; i <= abs(cnter); i++){
XA.push_back(X[i]); YA.push_back(Y[i]);
}
for(int i = 0; i <= N; i++) CA.push_back(C[i]);
answer(CA, XA, YA);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
6484 KB |
Output is correct |
2 |
Incorrect |
16 ms |
10152 KB |
Wrong Answer: wrong array length |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
6484 KB |
Output is correct |
2 |
Incorrect |
16 ms |
10152 KB |
Wrong Answer: wrong array length |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
6484 KB |
Output is correct |
2 |
Incorrect |
16 ms |
10152 KB |
Wrong Answer: wrong array length |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
6484 KB |
Wrong Answer: wrong array length |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
6484 KB |
Wrong Answer: wrong array length |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
6484 KB |
Wrong Answer: wrong array length |
2 |
Halted |
0 ms |
0 KB |
- |