#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)
{
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);
}
//printf("%d %d %d %d\n",N,here,X[-here],Y[-here]);
}
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);
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]]++;
}
}
//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 |
23 ms |
2496 KB |
Output is correct |
3 |
Correct |
19 ms |
1952 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
13 ms |
1764 KB |
Output is correct |
6 |
Correct |
29 ms |
2852 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 |
23 ms |
2496 KB |
Output is correct |
3 |
Correct |
19 ms |
1952 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
13 ms |
1764 KB |
Output is correct |
6 |
Correct |
29 ms |
2852 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
68 ms |
5792 KB |
Output is correct |
9 |
Correct |
46 ms |
5432 KB |
Output is correct |
10 |
Correct |
76 ms |
8500 KB |
Output is correct |
11 |
Correct |
1 ms |
332 KB |
Output is correct |
12 |
Correct |
1 ms |
332 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 |
23 ms |
2496 KB |
Output is correct |
3 |
Correct |
19 ms |
1952 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
13 ms |
1764 KB |
Output is correct |
6 |
Correct |
29 ms |
2852 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
68 ms |
5792 KB |
Output is correct |
9 |
Correct |
46 ms |
5432 KB |
Output is correct |
10 |
Correct |
76 ms |
8500 KB |
Output is correct |
11 |
Correct |
1 ms |
332 KB |
Output is correct |
12 |
Correct |
1 ms |
332 KB |
Output is correct |
13 |
Correct |
1 ms |
204 KB |
Output is correct |
14 |
Correct |
99 ms |
12512 KB |
Output is correct |
15 |
Correct |
54 ms |
6448 KB |
Output is correct |
16 |
Correct |
88 ms |
9612 KB |
Output is correct |
17 |
Correct |
1 ms |
204 KB |
Output is correct |
18 |
Correct |
2 ms |
204 KB |
Output is correct |
19 |
Correct |
1 ms |
204 KB |
Output is correct |
20 |
Correct |
86 ms |
10516 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 |
Incorrect |
2 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
1 ms |
332 KB |
Output is partially correct |
2 |
Correct |
78 ms |
7108 KB |
Output is correct |
3 |
Partially correct |
111 ms |
11416 KB |
Output is partially correct |
4 |
Partially correct |
141 ms |
12196 KB |
Output is partially correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
1 ms |
332 KB |
Output is partially correct |
2 |
Correct |
78 ms |
7108 KB |
Output is correct |
3 |
Partially correct |
111 ms |
11416 KB |
Output is partially correct |
4 |
Partially correct |
141 ms |
12196 KB |
Output is partially correct |
5 |
Partially correct |
119 ms |
13688 KB |
Output is partially correct |
6 |
Partially correct |
161 ms |
15468 KB |
Output is partially correct |
7 |
Partially correct |
125 ms |
14924 KB |
Output is partially correct |
8 |
Partially correct |
162 ms |
16620 KB |
Output is partially correct |
9 |
Partially correct |
118 ms |
11300 KB |
Output is partially correct |
10 |
Partially correct |
165 ms |
16944 KB |
Output is partially correct |
11 |
Partially correct |
191 ms |
17512 KB |
Output is partially correct |
12 |
Partially correct |
103 ms |
11584 KB |
Output is partially correct |
13 |
Partially correct |
83 ms |
10216 KB |
Output is partially correct |
14 |
Partially correct |
79 ms |
9736 KB |
Output is partially correct |
15 |
Partially correct |
75 ms |
8968 KB |
Output is partially correct |
16 |
Partially correct |
4 ms |
588 KB |
Output is partially correct |
17 |
Partially correct |
105 ms |
8980 KB |
Output is partially correct |
18 |
Partially correct |
89 ms |
8940 KB |
Output is partially correct |
19 |
Partially correct |
90 ms |
9604 KB |
Output is partially correct |
20 |
Partially correct |
169 ms |
12196 KB |
Output is partially correct |
21 |
Partially correct |
148 ms |
14980 KB |
Output is partially correct |
22 |
Partially correct |
125 ms |
12196 KB |
Output is partially correct |