#include <utility>
#include <algorithm>
#include <math.h>
#include <vector>
#include <set>
#include <iostream>
//#include "job.h"
#include "doll.h"
#define fori(i,n) for(int i=0;i<n;i++)
#define forn(i,n) for(int i=1;i<n;i++)
#define forib(i,n) for(int i=n-1;i>=0;i--)
#define fornb(i,n) for(int i=n-1;i>0;i--)
#define maxl 10000000000
#define con continue;
typedef long long lol;
using namespace std;
typedef vector<int> veci;
typedef pair<lol,lol> point;
lol sum=0;
void create_circuit(int M, std::vector<int> A) {
int N = A.size();
std::vector<int> C(M + 1);
C[0] = A[0];
for (int i = 1; i <= M; ++i) {
C[i] = -1;
}
vector<int> x, y;
if(N==1){
x.push_back(-1);
y.push_back(0);
answer(C, x, y);
return;
}
A.push_back(0);
int num=0;
while(1<<num < N){
num++;
}
veci depth,state;
depth.push_back(num);
x.push_back(0);
state.push_back(0);
y.push_back(0);
int cur=0;
int n=N;
while(depth[cur]>1){
if(n+(1<<(depth[cur]-1))<=(1<<num)){
x[cur]=-1;
n+=1<<(depth[cur]-1);
}else{
x[cur]=-(1+x.size());
depth.push_back(depth[cur]-1);
x.push_back(0);
state.push_back(0);
y.push_back(0);
}
y[cur]=-(1+x.size());
depth.push_back(depth[cur]-1);
x.push_back(0);
state.push_back(0);
y.push_back(0);
cur++;
}
if(n<(1<<num)){
x[cur]=-1;
}
int p=1;
cur=-1;
while(p<=N){
int lcur=-cur-1;
state[lcur]=1-state[lcur];
if(state[lcur]){
lcur=x[lcur];
}else{
lcur=y[lcur];
}
if(lcur==0){
lcur=-cur-1;
if(state[lcur]){
x[lcur]=A[p++];
}else{
y[lcur]=A[p++];
}
lcur=-1;
}
cur =lcur;
}
answer(C, x, y);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
45 ms |
4336 KB |
Output is correct |
3 |
Correct |
48 ms |
4176 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
12 ms |
1356 KB |
Output is correct |
6 |
Correct |
69 ms |
5600 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
45 ms |
4336 KB |
Output is correct |
3 |
Correct |
48 ms |
4176 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
12 ms |
1356 KB |
Output is correct |
6 |
Correct |
69 ms |
5600 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
79 ms |
7576 KB |
Output is correct |
9 |
Correct |
93 ms |
7232 KB |
Output is correct |
10 |
Correct |
130 ms |
9736 KB |
Output is correct |
11 |
Correct |
1 ms |
204 KB |
Output is correct |
12 |
Correct |
2 ms |
204 KB |
Output is correct |
13 |
Correct |
2 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
45 ms |
4336 KB |
Output is correct |
3 |
Correct |
48 ms |
4176 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
12 ms |
1356 KB |
Output is correct |
6 |
Correct |
69 ms |
5600 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
79 ms |
7576 KB |
Output is correct |
9 |
Correct |
93 ms |
7232 KB |
Output is correct |
10 |
Correct |
130 ms |
9736 KB |
Output is correct |
11 |
Correct |
1 ms |
204 KB |
Output is correct |
12 |
Correct |
2 ms |
204 KB |
Output is correct |
13 |
Correct |
2 ms |
204 KB |
Output is correct |
14 |
Correct |
128 ms |
9384 KB |
Output is correct |
15 |
Correct |
97 ms |
6552 KB |
Output is correct |
16 |
Correct |
185 ms |
8896 KB |
Output is correct |
17 |
Correct |
1 ms |
204 KB |
Output is correct |
18 |
Correct |
1 ms |
204 KB |
Output is correct |
19 |
Correct |
1 ms |
204 KB |
Output is correct |
20 |
Correct |
124 ms |
9500 KB |
Output is correct |
21 |
Correct |
1 ms |
204 KB |
Output is correct |
22 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
2 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
2 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
70 ms |
6520 KB |
Output is correct |
3 |
Correct |
83 ms |
6436 KB |
Output is correct |
4 |
Correct |
115 ms |
8616 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
70 ms |
6520 KB |
Output is correct |
3 |
Correct |
83 ms |
6436 KB |
Output is correct |
4 |
Correct |
115 ms |
8616 KB |
Output is correct |
5 |
Correct |
138 ms |
8868 KB |
Output is correct |
6 |
Correct |
121 ms |
8628 KB |
Output is correct |
7 |
Correct |
121 ms |
8632 KB |
Output is correct |
8 |
Correct |
121 ms |
8624 KB |
Output is correct |
9 |
Correct |
73 ms |
6456 KB |
Output is correct |
10 |
Correct |
115 ms |
8608 KB |
Output is correct |
11 |
Correct |
117 ms |
8572 KB |
Output is correct |
12 |
Correct |
80 ms |
6444 KB |
Output is correct |
13 |
Correct |
73 ms |
7136 KB |
Output is correct |
14 |
Correct |
80 ms |
6432 KB |
Output is correct |
15 |
Correct |
106 ms |
6576 KB |
Output is correct |
16 |
Correct |
7 ms |
460 KB |
Output is correct |
17 |
Correct |
70 ms |
6800 KB |
Output is correct |
18 |
Correct |
94 ms |
6724 KB |
Output is correct |
19 |
Correct |
124 ms |
6464 KB |
Output is correct |
20 |
Correct |
141 ms |
8580 KB |
Output is correct |
21 |
Correct |
172 ms |
8576 KB |
Output is correct |
22 |
Correct |
146 ms |
8608 KB |
Output is correct |