#include "doll.h"
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
const int N=5e5+10;
int g[N][2],nw[N];
bool bb[N],usu[N];
void create_circuit(int m, vi a) {
a.push_back(0);
int n=a.size(),w=1;
while(w<n) w*=2;
for(int i=w/2;i<w;i++) usu[i]=1;
for(int i=1;i<w/2;i++) g[i][0]=i*2,g[i][1]=i*2+1;
for(int i=w/2;i<w;i++) g[i][0]=-1,g[i][1]=-1;
for(int i=n;i>=1;i--){
int curr=1;
while(curr<w/2){
bb[curr]^=1;
curr=g[curr][bb[curr]];
}
bb[curr]^=1;
g[curr][bb[curr]]=a[i-1];
usu[curr]=0;
}
for(int i=w/2;i<w;i++){
if(g[i][0]==-1 and g[i][1]==-1) usu[i]=1;
}
for(int i=w/2-1;i>=1;i--){
if(usu[i*2] and usu[i*2+1]) usu[i]=1;
}
int li=0;
for(int i=1;i<w;i++){
if(usu[i]) continue;
nw[i]=++li;
}
vi c,x(li),y(li);
for(int i=0;i<=m;i++) c.push_back(-1);
for(int i=1;i<w/2;i++){
if(usu[i]) continue;
if(usu[i*2]) x[nw[i]-1]=-1;
else x[nw[i]-1]=-nw[g[i][0]];
if(usu[i*2+1]) y[nw[i]-1]=-1;
else y[nw[i]-1]=-nw[g[i][1]];
}
for(int i=w/2;i<w;i++){
if(usu[i]) continue;
x[nw[i]-1]=g[i][0];
y[nw[i]-1]=g[i][1];
}
//for(auto u:x) cout<<u<<"\n";
answer(c,x,y);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
2396 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
2396 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
2396 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
2396 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
1 ms |
2396 KB |
Output is partially correct |
2 |
Partially correct |
80 ms |
13904 KB |
Output is partially correct |
3 |
Partially correct |
85 ms |
14668 KB |
Output is partially correct |
4 |
Partially correct |
97 ms |
15684 KB |
Output is partially correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
1 ms |
2396 KB |
Output is partially correct |
2 |
Partially correct |
80 ms |
13904 KB |
Output is partially correct |
3 |
Partially correct |
85 ms |
14668 KB |
Output is partially correct |
4 |
Partially correct |
97 ms |
15684 KB |
Output is partially correct |
5 |
Partially correct |
67 ms |
16196 KB |
Output is partially correct |
6 |
Partially correct |
70 ms |
16088 KB |
Output is partially correct |
7 |
Partially correct |
66 ms |
15936 KB |
Output is partially correct |
8 |
Partially correct |
64 ms |
15936 KB |
Output is partially correct |
9 |
Partially correct |
54 ms |
14636 KB |
Output is partially correct |
10 |
Partially correct |
81 ms |
15904 KB |
Output is partially correct |
11 |
Partially correct |
64 ms |
15648 KB |
Output is partially correct |
12 |
Partially correct |
52 ms |
14776 KB |
Output is partially correct |
13 |
Partially correct |
60 ms |
14924 KB |
Output is partially correct |
14 |
Partially correct |
53 ms |
14932 KB |
Output is partially correct |
15 |
Partially correct |
53 ms |
14904 KB |
Output is partially correct |
16 |
Partially correct |
2 ms |
2784 KB |
Output is partially correct |
17 |
Correct |
34 ms |
9008 KB |
Output is correct |
18 |
Partially correct |
57 ms |
14672 KB |
Output is partially correct |
19 |
Partially correct |
50 ms |
14680 KB |
Output is partially correct |
20 |
Partially correct |
71 ms |
15784 KB |
Output is partially correct |
21 |
Partially correct |
63 ms |
15684 KB |
Output is partially correct |
22 |
Partially correct |
64 ms |
15680 KB |
Output is partially correct |