#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,A,B;
int w,n,nn,a[N];
int dfs(int L,int R,int l,int r)
{
if(l==r){
if(l==1)ans[a[++w]]=0;
return a[++w];
}
int x=A.size(),mid=L+R>>1;
A.push_back(0);
B.push_back(0);
if(r<=mid){
B[x]=-1;
A[x]=dfs(L,mid,l,r);
}
else{
B[x]=dfs(mid+1,R,mid+1,r);
A[x]=dfs(L,mid,l,mid);
}
return -x-1;
}
void create_circuit(int M, std::vector<int> A)
{
n=A.size();
for(int i=1;i<=n;++i)
a[i]=A[i-1];
nn=1;
while(nn>=n)nn<<=1;
if(n==1){
ans[0]=a[1];
for(int i=1;i<=M;++i)
ans[i]=0;
}
else{
for(int i=0;i<=M;++i)
ans.push_back(-1);
dfs(1,nn,1,n);
ans.push_back(-1);
}
answer(ans,A,B);
return;
}
Compilation message
doll.cpp: In function 'int dfs(int, int, int, int)':
doll.cpp:18:22: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
18 | int x=A.size(),mid=L+R>>1;
| ~^~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
129 ms |
262144 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
129 ms |
262144 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
129 ms |
262144 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
143 ms |
262144 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
125 ms |
262144 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
125 ms |
262144 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |