#include "doll.h"
#include <bits/stdc++.h>
using namespace std;
#define dbgv(v) cout<<#v<<" = "; f(i,0,v.size()) cout<<v[i]<<" "; cout<<endl
#define dbga(a,x,y) cout<<#a<<" = "; f(i,x,y) cout<<a[i]<<" "; cout<<endl
#define erorp(x) cout<<#x<<"={"<<x.F<<" , "<<x.S<<"}"<<endl
#define eror(x) cout<<#x<<'='<<(x)<<endl
#define f_(i,a,b) for(int i=a;i>=b;i--)
#define f(i,a,b) for(int i=a;i<b;i++)
#define nb(x) __builtin_popcount(x)
#define all(v) v.begin(),v.end()
#define bit(n,k) (((n)>>(k))&1)
#define Add(x,y) x=(x+y)%mod
#define maxm(a,b) a=max(a,b)
#define minm(a,b) a=min(a,b)
#define lst(x) x[x.size()-1]
#define sz(x) int(x.size())
#define mp make_pair
#define ll long long
#define pb push_back
#define S second
#define F first
const int N=2e5+99;
int n,m,lg,cnt;
vector<int> A,B;
int g[N][2];
void solve(int now,int ted){
if(ted==2) return ;
g[now][0]=++cnt;
solve(cnt,ted/2);
g[now][1]=++cnt;
solve(cnt,ted/2);
}
void create_circuit(int _m,vector<int> _A) {
f(i,0,N) g[i][0]=g[i][1]=N;
m=_m,n=_A.size(),A=_A;
f(i,0,30) if((1<<i)>n){
lg=i;
break;
}
cnt=lg;
f(i,1,lg){
if(bit(n,lg-i)){
g[i][0]=++cnt;
solve(cnt,(1<<(lg-i)));
}
else{
g[i][0]=1;
}
g[i][1]=i+1;
}
if(bit(n,0)==0){
g[lg][0]=1;
}
g[lg][1]=0;
int now=1,p=0;
while(now!=0){
if(now<0){
now=1;
continue ;
}
if(g[now][0]==N){
g[now][0]=-A[p]; p++;
}
swap(g[now][0],g[now][1]);
now=g[now][1];
}
vector<int> adj(m+1,-1);
vector<int> X,Y;
f(i,1,cnt+1) X.pb(-g[i][0]),Y.pb(-g[i][1]);
//dbgv(adj);
//dbgv(X);
//dbgv(Y);
answer(adj,X,Y);
}
/*
2 2
1 2
*/
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
1748 KB |
Output is correct |
2 |
Correct |
34 ms |
5320 KB |
Output is correct |
3 |
Correct |
32 ms |
5396 KB |
Output is correct |
4 |
Correct |
1 ms |
1844 KB |
Output is correct |
5 |
Correct |
10 ms |
3028 KB |
Output is correct |
6 |
Correct |
47 ms |
7472 KB |
Output is correct |
7 |
Correct |
1 ms |
1876 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
1748 KB |
Output is correct |
2 |
Correct |
34 ms |
5320 KB |
Output is correct |
3 |
Correct |
32 ms |
5396 KB |
Output is correct |
4 |
Correct |
1 ms |
1844 KB |
Output is correct |
5 |
Correct |
10 ms |
3028 KB |
Output is correct |
6 |
Correct |
47 ms |
7472 KB |
Output is correct |
7 |
Correct |
1 ms |
1876 KB |
Output is correct |
8 |
Correct |
62 ms |
8244 KB |
Output is correct |
9 |
Correct |
67 ms |
8628 KB |
Output is correct |
10 |
Correct |
87 ms |
11540 KB |
Output is correct |
11 |
Correct |
1 ms |
1848 KB |
Output is correct |
12 |
Correct |
1 ms |
1748 KB |
Output is correct |
13 |
Correct |
1 ms |
1876 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
1748 KB |
Output is correct |
2 |
Correct |
34 ms |
5320 KB |
Output is correct |
3 |
Correct |
32 ms |
5396 KB |
Output is correct |
4 |
Correct |
1 ms |
1844 KB |
Output is correct |
5 |
Correct |
10 ms |
3028 KB |
Output is correct |
6 |
Correct |
47 ms |
7472 KB |
Output is correct |
7 |
Correct |
1 ms |
1876 KB |
Output is correct |
8 |
Correct |
62 ms |
8244 KB |
Output is correct |
9 |
Correct |
67 ms |
8628 KB |
Output is correct |
10 |
Correct |
87 ms |
11540 KB |
Output is correct |
11 |
Correct |
1 ms |
1848 KB |
Output is correct |
12 |
Correct |
1 ms |
1748 KB |
Output is correct |
13 |
Correct |
1 ms |
1876 KB |
Output is correct |
14 |
Correct |
87 ms |
11172 KB |
Output is correct |
15 |
Correct |
62 ms |
7056 KB |
Output is correct |
16 |
Correct |
88 ms |
9588 KB |
Output is correct |
17 |
Correct |
1 ms |
1748 KB |
Output is correct |
18 |
Correct |
1 ms |
1748 KB |
Output is correct |
19 |
Correct |
1 ms |
1748 KB |
Output is correct |
20 |
Correct |
87 ms |
11296 KB |
Output is correct |
21 |
Correct |
1 ms |
1748 KB |
Output is correct |
22 |
Correct |
1 ms |
1748 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
1748 KB |
Output is correct |
2 |
Correct |
1 ms |
1748 KB |
Output is correct |
3 |
Correct |
1 ms |
1748 KB |
Output is correct |
4 |
Correct |
1 ms |
1748 KB |
Output is correct |
5 |
Correct |
1 ms |
1748 KB |
Output is correct |
6 |
Correct |
1 ms |
1748 KB |
Output is correct |
7 |
Correct |
1 ms |
1748 KB |
Output is correct |
8 |
Correct |
1 ms |
1748 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
1748 KB |
Output is correct |
2 |
Correct |
53 ms |
7184 KB |
Output is correct |
3 |
Correct |
52 ms |
7192 KB |
Output is correct |
4 |
Correct |
85 ms |
10468 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
1748 KB |
Output is correct |
2 |
Correct |
53 ms |
7184 KB |
Output is correct |
3 |
Correct |
52 ms |
7192 KB |
Output is correct |
4 |
Correct |
85 ms |
10468 KB |
Output is correct |
5 |
Correct |
86 ms |
10644 KB |
Output is correct |
6 |
Correct |
88 ms |
10604 KB |
Output is correct |
7 |
Correct |
84 ms |
10660 KB |
Output is correct |
8 |
Correct |
85 ms |
10552 KB |
Output is correct |
9 |
Correct |
56 ms |
7352 KB |
Output is correct |
10 |
Correct |
81 ms |
10436 KB |
Output is correct |
11 |
Correct |
83 ms |
10448 KB |
Output is correct |
12 |
Correct |
54 ms |
7308 KB |
Output is correct |
13 |
Correct |
54 ms |
7640 KB |
Output is correct |
14 |
Correct |
55 ms |
7724 KB |
Output is correct |
15 |
Correct |
57 ms |
7820 KB |
Output is correct |
16 |
Correct |
2 ms |
2004 KB |
Output is correct |
17 |
Correct |
51 ms |
7452 KB |
Output is correct |
18 |
Correct |
54 ms |
7312 KB |
Output is correct |
19 |
Correct |
55 ms |
7432 KB |
Output is correct |
20 |
Correct |
83 ms |
10512 KB |
Output is correct |
21 |
Correct |
84 ms |
10596 KB |
Output is correct |
22 |
Correct |
78 ms |
10472 KB |
Output is correct |