#include "doll.h"
#include <bits/stdc++.h>
#define sz(a) (int)a.size()
#define all(x) (x).begin(), (x).end()
using namespace std;
void create_circuit(int M, std::vector<int> A){
int N=sz(A);
vector<int> C(M+1,0);
vector<vector<int>> nxt(M+1);
vector<int> X;
vector<int> Y;
for (int i = 1; i < N; i++)
{
nxt[A[i-1]].push_back(A[i]);
}
nxt[A[N-1]].push_back(0);
C[0]=A[0];
int trig=-1;
for (int i = 1; i <= M; i++)
{
int logo=log2((sz(nxt[i])*2)-1) ;
if(sz(nxt[i])==1){
C[i]=nxt[i][0];
}else if(logo==1){
C[i]=trig;
trig--;
X.push_back(nxt[i][0]);
Y.push_back(nxt[i][1]);
}else if(logo==2){
C[i]=trig;
X.push_back(trig-1);
Y.push_back(trig-2);
X.push_back(nxt[i][0]);
X.push_back(nxt[i][1]);
if(sz(nxt[i])==3) {
Y.push_back(trig);
Y.push_back(nxt[i][2]);
}
else {
Y.push_back(nxt[i][2]);
Y.push_back(nxt[i][3]);
}
trig-=3;
}else if(logo==3){;
C[i]=trig;
X.push_back(trig-1);
Y.push_back(trig-2);
X.push_back(trig-3);
Y.push_back(trig-4);
X.push_back(trig-5);
Y.push_back(trig-6);
X.push_back(nxt[i][0]);
X.push_back(nxt[i][2]);
X.push_back(nxt[i][1]);
X.push_back(nxt[i][3]);
if(sz(nxt[i])==8) {
Y.push_back(nxt[i][4]);
Y.push_back(nxt[i][6]);
Y.push_back(nxt[i][5]);
Y.push_back(nxt[i][7]);
}else if(sz(nxt[i])==7) {
Y.push_back(nxt[i][4]);
Y.push_back(trig);
Y.push_back(nxt[i][5]);
Y.push_back(nxt[i][6]);
}else if(sz(nxt[i])==6){
Y.push_back(nxt[i][4]);
Y.push_back(trig);
Y.push_back(trig);
Y.push_back(nxt[i][5]);
}else{
Y.push_back(trig);
Y.push_back(trig);
Y.push_back(trig);
Y.push_back(nxt[i][4]);
}
trig-=7;
}else{
C[i]=trig;
X.push_back(trig-1);
Y.push_back(trig-2);
X.push_back(trig-3);
Y.push_back(trig-4);
X.push_back(trig-5);
Y.push_back(trig-6);
X.push_back(trig-7);
Y.push_back(trig-8);
X.push_back(trig-9);
Y.push_back(trig-10);
X.push_back(trig-11);
Y.push_back(trig-12);
X.push_back(trig-13);
Y.push_back(trig-14);
X.push_back(nxt[i][0]);
X.push_back(nxt[i][4]);
X.push_back(nxt[i][2]);
X.push_back(nxt[i][6]);
X.push_back(nxt[i][1]);
X.push_back(nxt[i][5]);
X.push_back(nxt[i][3]);
X.push_back(nxt[i][7]);
if(sz(nxt[i])==16) {
Y.push_back(nxt[i][8]);
Y.push_back(nxt[i][12]);
Y.push_back(nxt[i][10]);
Y.push_back(nxt[i][14]);
Y.push_back(nxt[i][9]);
Y.push_back(nxt[i][13]);
Y.push_back(nxt[i][11]);
Y.push_back(nxt[i][15]);
}else if(sz(nxt[i])==15) {
Y.push_back(nxt[i][8]);
Y.push_back(nxt[i][12]);
Y.push_back(nxt[i][10]);
Y.push_back(trig);
Y.push_back(nxt[i][9]);
Y.push_back(nxt[i][13]);
Y.push_back(nxt[i][11]);
Y.push_back(nxt[i][14]);
}else if(sz(nxt[i])==14){
Y.push_back(nxt[i][8]);
Y.push_back(nxt[i][12]);
Y.push_back(nxt[i][10]);
Y.push_back(trig);
Y.push_back(nxt[i][9]);
Y.push_back(trig);
Y.push_back(nxt[i][11]);
Y.push_back(nxt[i][13]);
}else if(sz(nxt[i])==13){
Y.push_back(nxt[i][8]);
Y.push_back(trig);
Y.push_back(nxt[i][10]);
Y.push_back(trig);
Y.push_back(nxt[i][9]);
Y.push_back(trig);
Y.push_back(nxt[i][11]);
Y.push_back(nxt[i][12]);
}else if(sz(nxt[i])==12){
Y.push_back(nxt[i][8]);
Y.push_back(trig);
Y.push_back(nxt[i][10]);
Y.push_back(trig);
Y.push_back(nxt[i][9]);
Y.push_back(trig);
Y.push_back(trig);
Y.push_back(nxt[i][11]);
}else if(sz(nxt[i])==11){
Y.push_back(nxt[i][8]);
Y.push_back(trig);
Y.push_back(trig);
Y.push_back(trig);
Y.push_back(nxt[i][9]);
Y.push_back(trig);
Y.push_back(trig);
Y.push_back(nxt[i][10]);
}else if(sz(nxt[i])==10){
Y.push_back(nxt[i][8]);
Y.push_back(trig);
Y.push_back(trig);
Y.push_back(trig);
Y.push_back(trig);
Y.push_back(trig);
Y.push_back(trig);
Y.push_back(nxt[i][9]);
}else if(sz(nxt[i])==9){
Y.push_back(trig);
Y.push_back(trig);
Y.push_back(trig);
Y.push_back(trig);
Y.push_back(trig);
Y.push_back(trig);
Y.push_back(trig);
Y.push_back(nxt[i][8]);
}
trig-=15;
}
}
for (int i = 0; i <= M; i++)
{
//cerr << C[i] << " ";
}
//cerr<<"\n";
for (int i = 0; i < sz(Y); i++){
//cerr << X[i] << " " << Y[i] << "\n";
}
answer(C,{X},{Y});
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Runtime error |
12 ms |
11744 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Runtime error |
12 ms |
11744 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Runtime error |
12 ms |
11744 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
348 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Wrong Answer: wrong array length |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Wrong Answer: wrong array length |
2 |
Halted |
0 ms |
0 KB |
- |