#include "doll.h"
#include<bits/stdc++.h>
using namespace std;
vector<int>to[100015],g[100015];
vector<int>ans1,ans2,c;
int n,m,now=0;
int build(int num,int l,int r,int root){
if (l==r){
if (g[num][l]==-1) return -root;
else return -g[num][l];
}
int mid=(l+r)>>1,use=--now;
use=abs(use);
int p1=build(num,l,mid,root);
ans1[use]=-p1;
int p2=build(num,mid+1,r,root);
ans2[use]=-p2;
return use;
}
void create_circuit(int M, std::vector<int> A) {
m=M;
ans1.resize(400000); ans2.resize(400000);
A.insert(A.begin(),0);
A.push_back(0);
n = A.size();
for (int i=0;i<n-1;i++){
to[A[i]].push_back(A[i+1]);
}
for (int i=0;i<=m;i++){
if (to[i].empty()) continue;
int p=0;
for (int j=0; ;j++){
if ((1LL<<j)>=(int)to[i].size()){
p=j;
break;
}
}
g[i].resize((1LL<<p),-1);
for (int j=0;j<to[i].size();j++){
int idx=0;
for (int k=0;k<p;k++){
if (j&(1LL<<k))
idx=(idx+(1LL<<(p-k-1)));
}
if (j==to[i].size()-1)
g[i][(1LL<<p)-1]=to[i][j];
else g[i][idx]=to[i][j];
}
}
c.resize(m+1);
for (int i=0;i<=m;i++){
if (g[i].empty()) c[i]=0;
else if (g[i].size()==1) c[i]=g[i][0];
else c[i]=-build(i,0,g[i].size()-1,now-1);
}
now=abs(now);
vector<int>X,Y;
for (int i=1;i<=now;i++){
X.push_back(ans1[i]);
}
for (int i=1;i<=now;i++){
Y.push_back(ans2[i]);
}
answer(c, X, Y);
}
Compilation message
doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:39:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
39 | for (int j=0;j<to[i].size();j++){
| ~^~~~~~~~~~~~~
doll.cpp:45:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
45 | if (j==to[i].size()-1)
| ~^~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
8120 KB |
Output is correct |
2 |
Correct |
33 ms |
13924 KB |
Output is correct |
3 |
Correct |
30 ms |
13628 KB |
Output is correct |
4 |
Correct |
4 ms |
8020 KB |
Output is correct |
5 |
Correct |
12 ms |
9300 KB |
Output is correct |
6 |
Correct |
40 ms |
16516 KB |
Output is correct |
7 |
Correct |
4 ms |
8020 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
8120 KB |
Output is correct |
2 |
Correct |
33 ms |
13924 KB |
Output is correct |
3 |
Correct |
30 ms |
13628 KB |
Output is correct |
4 |
Correct |
4 ms |
8020 KB |
Output is correct |
5 |
Correct |
12 ms |
9300 KB |
Output is correct |
6 |
Correct |
40 ms |
16516 KB |
Output is correct |
7 |
Correct |
4 ms |
8020 KB |
Output is correct |
8 |
Correct |
47 ms |
16440 KB |
Output is correct |
9 |
Correct |
57 ms |
17480 KB |
Output is correct |
10 |
Correct |
68 ms |
20600 KB |
Output is correct |
11 |
Correct |
4 ms |
8020 KB |
Output is correct |
12 |
Correct |
4 ms |
8020 KB |
Output is correct |
13 |
Correct |
5 ms |
8020 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
8120 KB |
Output is correct |
2 |
Correct |
33 ms |
13924 KB |
Output is correct |
3 |
Correct |
30 ms |
13628 KB |
Output is correct |
4 |
Correct |
4 ms |
8020 KB |
Output is correct |
5 |
Correct |
12 ms |
9300 KB |
Output is correct |
6 |
Correct |
40 ms |
16516 KB |
Output is correct |
7 |
Correct |
4 ms |
8020 KB |
Output is correct |
8 |
Correct |
47 ms |
16440 KB |
Output is correct |
9 |
Correct |
57 ms |
17480 KB |
Output is correct |
10 |
Correct |
68 ms |
20600 KB |
Output is correct |
11 |
Correct |
4 ms |
8020 KB |
Output is correct |
12 |
Correct |
4 ms |
8020 KB |
Output is correct |
13 |
Correct |
5 ms |
8020 KB |
Output is correct |
14 |
Correct |
82 ms |
20140 KB |
Output is correct |
15 |
Correct |
46 ms |
14932 KB |
Output is correct |
16 |
Correct |
72 ms |
17160 KB |
Output is correct |
17 |
Correct |
4 ms |
8020 KB |
Output is correct |
18 |
Correct |
4 ms |
8020 KB |
Output is correct |
19 |
Correct |
5 ms |
8020 KB |
Output is correct |
20 |
Correct |
77 ms |
19588 KB |
Output is correct |
21 |
Correct |
4 ms |
8020 KB |
Output is correct |
22 |
Correct |
5 ms |
8020 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
8148 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
4 ms |
8148 KB |
Output is partially correct |
2 |
Correct |
47 ms |
14672 KB |
Output is correct |
3 |
Partially correct |
82 ms |
16904 KB |
Output is partially correct |
4 |
Partially correct |
80 ms |
17664 KB |
Output is partially correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
4 ms |
8148 KB |
Output is partially correct |
2 |
Correct |
47 ms |
14672 KB |
Output is correct |
3 |
Partially correct |
82 ms |
16904 KB |
Output is partially correct |
4 |
Partially correct |
80 ms |
17664 KB |
Output is partially correct |
5 |
Partially correct |
92 ms |
20792 KB |
Output is partially correct |
6 |
Partially correct |
103 ms |
21516 KB |
Output is partially correct |
7 |
Partially correct |
96 ms |
21124 KB |
Output is partially correct |
8 |
Partially correct |
104 ms |
21944 KB |
Output is partially correct |
9 |
Partially correct |
71 ms |
17048 KB |
Output is partially correct |
10 |
Partially correct |
104 ms |
21520 KB |
Output is partially correct |
11 |
Partially correct |
113 ms |
22224 KB |
Output is partially correct |
12 |
Partially correct |
67 ms |
17420 KB |
Output is partially correct |
13 |
Partially correct |
67 ms |
16832 KB |
Output is partially correct |
14 |
Partially correct |
70 ms |
16572 KB |
Output is partially correct |
15 |
Partially correct |
61 ms |
16408 KB |
Output is partially correct |
16 |
Partially correct |
5 ms |
8404 KB |
Output is partially correct |
17 |
Partially correct |
57 ms |
15564 KB |
Output is partially correct |
18 |
Partially correct |
70 ms |
15628 KB |
Output is partially correct |
19 |
Partially correct |
66 ms |
16148 KB |
Output is partially correct |
20 |
Partially correct |
85 ms |
18448 KB |
Output is partially correct |
21 |
Partially correct |
93 ms |
20680 KB |
Output is partially correct |
22 |
Partially correct |
75 ms |
17852 KB |
Output is partially correct |