#include "doll.h"
#include <vector>
#include <stdio.h>
using namespace std;
int con[1000005]={0};
int This[1000005]={0};
int m[1000005];
int n[1000005];
int start[1000005]={0};
vector < int > C,x,y;
int X[1000005]={0};
int Y[1000005]={0};
int now=1;
int t[1000005]={0};
int how[1000005]={0};
void build(int N,int here,int a,int b)
{
//printf("%d %d\n",N,here);
if(N==2)
{
X[-here]=a;
Y[-here]=b;
}
else if(N%2==0)
{
X[-here]=(-now);
now++;
Y[-here]=(-now);
now++;
build(N/2,X[-here],a,b);
build(N/2,Y[-here],0,0);
}
else
{
X[-here]=(-now);
now++;
Y[-here]=(-now);
now++;
build(N/2+1,X[-here],a,b);
build(N/2+1,Y[-here],here,0);
}
}
void New(int here,int what)
{
if(how[-here]%2==0)
{
how[-here]++;
if(X[-here]) New(X[-here],what);
else X[-here]=what;
}
else
{
how[-here]++;
if(Y[-here]) New(Y[-here],what);
else Y[-here]=what;
}
}
void create_circuit(int M, vector < int > A)
{
int N=A.size(),i,temp;
C.push_back(A[0]);
for(i=1;i<=M;i++) C.push_back(i);
for(i=0;i<N;i++) con[A[i]]++;
A.push_back(0);
if(N!=16)
{
for(i=0;i<N;i++)
{
if(con[A[i]]==1)
{
C[A[i]]=A[i+1];
}
else
{
if(!This[A[i]])
{
C[A[i]]=-now;
now++;
build(con[A[i]],C[A[i]],0,0);
}
New(C[A[i]],A[i+1]);
This[A[i]]++;
}
}
}
else
{
now++;
build(N,-1,0,0);
for(i=0;i<N;i++)
{
C[A[i]]=-1;
New(C[A[i]],A[i+1]);
}
}
//printf("a %d\n",now-1);
//for(auto i:C) printf("%d ",i);
//printf("\n");
//for(i=1;i<now;i++) printf("%d %d\n",X[i],Y[i]);
for(i=1;i<now;i++) x.push_back(X[i]);
for(i=1;i<now;i++) y.push_back(Y[i]);
answer(C,x,y);
}
Compilation message
doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:64:22: warning: unused variable 'temp' [-Wunused-variable]
64 | int N=A.size(),i,temp;
| ^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
24 ms |
2492 KB |
Output is correct |
3 |
Correct |
19 ms |
1980 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
13 ms |
1836 KB |
Output is correct |
6 |
Correct |
29 ms |
2732 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 |
24 ms |
2492 KB |
Output is correct |
3 |
Correct |
19 ms |
1980 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
13 ms |
1836 KB |
Output is correct |
6 |
Correct |
29 ms |
2732 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
48 ms |
5872 KB |
Output is correct |
9 |
Correct |
52 ms |
5424 KB |
Output is correct |
10 |
Correct |
77 ms |
8576 KB |
Output is correct |
11 |
Correct |
2 ms |
204 KB |
Output is correct |
12 |
Correct |
1 ms |
204 KB |
Output is correct |
13 |
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 |
24 ms |
2492 KB |
Output is correct |
3 |
Correct |
19 ms |
1980 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
13 ms |
1836 KB |
Output is correct |
6 |
Correct |
29 ms |
2732 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
48 ms |
5872 KB |
Output is correct |
9 |
Correct |
52 ms |
5424 KB |
Output is correct |
10 |
Correct |
77 ms |
8576 KB |
Output is correct |
11 |
Correct |
2 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 |
102 ms |
12600 KB |
Output is correct |
15 |
Correct |
52 ms |
6392 KB |
Output is correct |
16 |
Correct |
84 ms |
9600 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 |
92 ms |
10512 KB |
Output is correct |
21 |
Correct |
2 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 |
2 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 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
1 ms |
332 KB |
Output is partially correct |
2 |
Correct |
92 ms |
7144 KB |
Output is correct |
3 |
Partially correct |
126 ms |
11340 KB |
Output is partially correct |
4 |
Partially correct |
144 ms |
12176 KB |
Output is partially correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
1 ms |
332 KB |
Output is partially correct |
2 |
Correct |
92 ms |
7144 KB |
Output is correct |
3 |
Partially correct |
126 ms |
11340 KB |
Output is partially correct |
4 |
Partially correct |
144 ms |
12176 KB |
Output is partially correct |
5 |
Partially correct |
142 ms |
13724 KB |
Output is partially correct |
6 |
Partially correct |
140 ms |
15468 KB |
Output is partially correct |
7 |
Partially correct |
130 ms |
14964 KB |
Output is partially correct |
8 |
Partially correct |
164 ms |
16692 KB |
Output is partially correct |
9 |
Partially correct |
127 ms |
11396 KB |
Output is partially correct |
10 |
Partially correct |
176 ms |
17020 KB |
Output is partially correct |
11 |
Partially correct |
159 ms |
17520 KB |
Output is partially correct |
12 |
Partially correct |
104 ms |
11572 KB |
Output is partially correct |
13 |
Partially correct |
82 ms |
10228 KB |
Output is partially correct |
14 |
Partially correct |
82 ms |
9724 KB |
Output is partially correct |
15 |
Partially correct |
75 ms |
8968 KB |
Output is partially correct |
16 |
Partially correct |
3 ms |
588 KB |
Output is partially correct |
17 |
Partially correct |
86 ms |
8924 KB |
Output is partially correct |
18 |
Partially correct |
95 ms |
8932 KB |
Output is partially correct |
19 |
Partially correct |
93 ms |
9716 KB |
Output is partially correct |
20 |
Partially correct |
118 ms |
12140 KB |
Output is partially correct |
21 |
Partially correct |
194 ms |
15032 KB |
Output is partially correct |
22 |
Partially correct |
121 ms |
12212 KB |
Output is partially correct |