#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include <vector>
#define ll long long
#define N 202300
#include "doll.h"
using namespace std;
vector<int>ans,P,Q;
int w,n,nn,v[N],a[N];
int dfs(int L,int R,int l,int r)
{
if(L==R){
if(L==1)return 0;
return v[l];
}
int x=P.size(),y,z,mid=L+R>>1;
P.push_back(0);
Q.push_back(0);
if(r<=mid){
y=-1;
z=dfs(L,mid,l,r);
}
else{
y=dfs(mid+1,R,mid+1,r);
z=dfs(L,mid,l,mid);
}
P[x]=y;
Q[x]=z;
return -x-1;
}
bool cmp(int x,int y)
{
while((x&1)==(y&1)){
x>>=1;
y>>=1;
}
return (x&1)>(y&1);
}
void create_circuit(int M, std::vector<int> A)
{
n=A.size();
for(int i=1;i<=n;++i)
a[i]=i;
sort(a+1,a+1+n,cmp);
for(int i=1;i<=n;++i)
v[a[i]+1]=A[i-1];
nn=1;
while(nn<n+1)nn<<=1;
if(n==1){
ans.push_back(A[0]);
for(int i=1;i<=M;++i)
ans.push_back(0);
}
else{
for(int i=0;i<=M;++i)
ans.push_back(-1);
dfs(1,nn,1,n+1);
}
answer(ans,P,Q);
return;
}
Compilation message
doll.cpp: In function 'int dfs(int, int, int, int)':
doll.cpp:18:26: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
18 | int x=P.size(),y,z,mid=L+R>>1;
| ~^~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
44 ms |
5176 KB |
Output is correct |
3 |
Correct |
42 ms |
5068 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
10 ms |
1612 KB |
Output is correct |
6 |
Correct |
69 ms |
6608 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
44 ms |
5176 KB |
Output is correct |
3 |
Correct |
42 ms |
5068 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
10 ms |
1612 KB |
Output is correct |
6 |
Correct |
69 ms |
6608 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
79 ms |
8492 KB |
Output is correct |
9 |
Correct |
94 ms |
9048 KB |
Output is correct |
10 |
Correct |
125 ms |
12168 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
312 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
44 ms |
5176 KB |
Output is correct |
3 |
Correct |
42 ms |
5068 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
10 ms |
1612 KB |
Output is correct |
6 |
Correct |
69 ms |
6608 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
79 ms |
8492 KB |
Output is correct |
9 |
Correct |
94 ms |
9048 KB |
Output is correct |
10 |
Correct |
125 ms |
12168 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
312 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
156 ms |
11616 KB |
Output is correct |
15 |
Correct |
77 ms |
8044 KB |
Output is correct |
16 |
Correct |
120 ms |
10548 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
1 ms |
212 KB |
Output is correct |
19 |
Correct |
1 ms |
212 KB |
Output is correct |
20 |
Correct |
125 ms |
11872 KB |
Output is correct |
21 |
Correct |
1 ms |
308 KB |
Output is correct |
22 |
Correct |
1 ms |
304 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
308 KB |
Output is correct |
3 |
Correct |
1 ms |
308 KB |
Output is correct |
4 |
Correct |
1 ms |
308 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
308 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
95 ms |
6976 KB |
Output is correct |
3 |
Correct |
81 ms |
7024 KB |
Output is correct |
4 |
Correct |
121 ms |
9724 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
95 ms |
6976 KB |
Output is correct |
3 |
Correct |
81 ms |
7024 KB |
Output is correct |
4 |
Correct |
121 ms |
9724 KB |
Output is correct |
5 |
Correct |
123 ms |
10488 KB |
Output is correct |
6 |
Correct |
124 ms |
10216 KB |
Output is correct |
7 |
Correct |
125 ms |
10224 KB |
Output is correct |
8 |
Correct |
124 ms |
10020 KB |
Output is correct |
9 |
Correct |
83 ms |
6964 KB |
Output is correct |
10 |
Correct |
119 ms |
9928 KB |
Output is correct |
11 |
Correct |
117 ms |
9716 KB |
Output is correct |
12 |
Correct |
76 ms |
7232 KB |
Output is correct |
13 |
Correct |
79 ms |
7596 KB |
Output is correct |
14 |
Correct |
80 ms |
7772 KB |
Output is correct |
15 |
Correct |
94 ms |
7852 KB |
Output is correct |
16 |
Correct |
4 ms |
468 KB |
Output is correct |
17 |
Correct |
92 ms |
6516 KB |
Output is correct |
18 |
Correct |
80 ms |
7216 KB |
Output is correct |
19 |
Correct |
79 ms |
7276 KB |
Output is correct |
20 |
Correct |
127 ms |
9828 KB |
Output is correct |
21 |
Correct |
122 ms |
9688 KB |
Output is correct |
22 |
Correct |
113 ms |
9704 KB |
Output is correct |