#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,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];
}
return a[++w];
}
int x=P.size(),mid=L+R>>1;
P.push_back(0);
Q.push_back(0);
if(r<=mid){
Q[x]=-1;
P[x]=dfs(L,mid,l,r);
}
else{
Q[x]=dfs(mid+1,R,mid+1,r);
P[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.push_back(a[1]);
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);
}
answer(ans,P,Q);
return;
}
Compilation message
doll.cpp: In function 'int dfs(int, int, int, int)':
doll.cpp:21:22: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
21 | int x=P.size(),mid=L+R>>1;
| ~^~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
wrong motion |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
wrong motion |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
wrong motion |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
wrong motion |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
332 KB |
wrong motion |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
332 KB |
wrong motion |
2 |
Halted |
0 ms |
0 KB |
- |