#include "doll.h"
#include <bits/stdc++.h>
using namespace std;
template<class A> using v=vector<A>;
typedef v<int> vi;
#define sz(S) (int)(S).size()
#define pb push_back
#define get4(a,b,c,d,...) d
#define lp3(x,a,b) for(int x=(a);x<(b);x++)
#define lp2(x,a) lp3(x,0,a)
#define lp1(a) lp2(loopvar,a)
#define lp(x...) get4(x,lp3,lp2,lp1,0)(x)
#define trv(x,S) for(auto& x:(S))
const int mx=800100;
int n,m,bn,s,ful;
int tgt[mx];
int out[2][mx];
bool state[mx];
int makenet(int dpt)
{
if(dpt==0) return 0;
int ts=s;
s++;
out[0][ts]=makenet(dpt-1);
out[1][ts]=makenet(dpt-1);
return -ts;
}
void explore(int v,int p)
{
if(v==0)
{
out[!state[p]][p]=tgt[ful],ful++;
return;
}
state[v]=!state[v];
explore(-out[!state[v]][v],v);
}
void create_circuit(int M, vi A)
{
m=M;
n=sz(A);
lp(i,n) tgt[i]=A[i];
vi bita;
{
int i1=n;
while(i1>0) bita.pb(i1%2),i1/=2;
}
bn=sz(bita);
lp(i,1,bn) out[1][i]=-(i+1);
out[1][bn]=0;
s=bn+1;
lp(i,1,bn+1) out[0][i]=bita[bn-i]?makenet(bn-i):-1;
lp(i,1,s+1) state[i]=0;
ful=0;
lp(n) explore(1,-1);
vi C(m+1);
lp(i,m+1) C[i]=-1;
vi X,Y;
lp(i,1,s) X.pb(out[0][i]);
lp(i,1,s) Y.pb(out[1][i]);
answer(C, X, Y);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
49 ms |
4368 KB |
Output is correct |
3 |
Correct |
52 ms |
3980 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
13 ms |
1484 KB |
Output is correct |
6 |
Correct |
76 ms |
5964 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
49 ms |
4368 KB |
Output is correct |
3 |
Correct |
52 ms |
3980 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
13 ms |
1484 KB |
Output is correct |
6 |
Correct |
76 ms |
5964 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
107 ms |
6948 KB |
Output is correct |
9 |
Correct |
95 ms |
7340 KB |
Output is correct |
10 |
Correct |
140 ms |
10292 KB |
Output is correct |
11 |
Correct |
1 ms |
204 KB |
Output is correct |
12 |
Correct |
1 ms |
204 KB |
Output is correct |
13 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
49 ms |
4368 KB |
Output is correct |
3 |
Correct |
52 ms |
3980 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
13 ms |
1484 KB |
Output is correct |
6 |
Correct |
76 ms |
5964 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
107 ms |
6948 KB |
Output is correct |
9 |
Correct |
95 ms |
7340 KB |
Output is correct |
10 |
Correct |
140 ms |
10292 KB |
Output is correct |
11 |
Correct |
1 ms |
204 KB |
Output is correct |
12 |
Correct |
1 ms |
204 KB |
Output is correct |
13 |
Correct |
1 ms |
204 KB |
Output is correct |
14 |
Correct |
186 ms |
9912 KB |
Output is correct |
15 |
Correct |
91 ms |
6564 KB |
Output is correct |
16 |
Correct |
133 ms |
9688 KB |
Output is correct |
17 |
Correct |
1 ms |
204 KB |
Output is correct |
18 |
Correct |
1 ms |
332 KB |
Output is correct |
19 |
Correct |
1 ms |
204 KB |
Output is correct |
20 |
Correct |
141 ms |
10060 KB |
Output is correct |
21 |
Correct |
2 ms |
204 KB |
Output is correct |
22 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 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 |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
85 ms |
6056 KB |
Output is correct |
3 |
Correct |
84 ms |
6076 KB |
Output is correct |
4 |
Correct |
129 ms |
9276 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
85 ms |
6056 KB |
Output is correct |
3 |
Correct |
84 ms |
6076 KB |
Output is correct |
4 |
Correct |
129 ms |
9276 KB |
Output is correct |
5 |
Correct |
137 ms |
9536 KB |
Output is correct |
6 |
Correct |
170 ms |
9292 KB |
Output is correct |
7 |
Correct |
131 ms |
9400 KB |
Output is correct |
8 |
Correct |
129 ms |
9288 KB |
Output is correct |
9 |
Correct |
84 ms |
6076 KB |
Output is correct |
10 |
Correct |
136 ms |
9284 KB |
Output is correct |
11 |
Correct |
144 ms |
9272 KB |
Output is correct |
12 |
Correct |
88 ms |
6092 KB |
Output is correct |
13 |
Correct |
87 ms |
6340 KB |
Output is correct |
14 |
Correct |
86 ms |
6420 KB |
Output is correct |
15 |
Correct |
103 ms |
6544 KB |
Output is correct |
16 |
Correct |
3 ms |
460 KB |
Output is correct |
17 |
Correct |
78 ms |
6228 KB |
Output is correct |
18 |
Correct |
87 ms |
6076 KB |
Output is correct |
19 |
Correct |
86 ms |
6080 KB |
Output is correct |
20 |
Correct |
131 ms |
9276 KB |
Output is correct |
21 |
Correct |
127 ms |
9276 KB |
Output is correct |
22 |
Correct |
135 ms |
9160 KB |
Output is correct |