Mentality, this game does not seem entirely from the last game out of the shadow
Look T1 compare panic, especially receiving fake affect next two big brothers, and that T1 is water, but ultimately did not see how to do, to put the
T2 at first glance more like-like pressure, feeling and unstable, so on the back
So it is better to write a T3 written by violence,
Finally T1 violence did not finish
The entire T2 only started writing like pressure when it feels more stable, really into the state
Overall amount of thinking in general, T2 think after 30 minutes and then there will be no thought
T2 "shaped pressure DP"
This definition of a s 0/1 represents the OFF / ON state
Then each time t which will Lin Xiansen operating state during the time the parent node negated. If the spread is not the root pass 1
First, find a property: the case of cancellation do not control.
why? You will find that no matter the situation you cancel, make two passes were operating, the final result is the same
Then we will go to want to push forward a positive, because in the end the answer is no guarantee stable, so it was not a time to determine the contribution of one operation
And fell sake do not have this problem,
We define f [t] [s] represents the reciprocal of t seconds, the current state is s, the presence or absence
f [0] [ed] = 1, we want to first present state s == 0, then the output time can be
After the first pre-out operation for each point, the contribution of the time t
I wrote a very good transfer
//decoration #include<bits/stdc++.h> using namespace std; int fa[20],f[50][1<<17]; int st[20][50]; int n,ed,mx; int main () { freopen("decoration.in","r",stdin); freopen("decoration.out","w",stdout); scanf("%d",&n); for(int i=2;i<=n;++i) scanf("%d",&fa[i]); for(int i=1;i<=n;++i){ int x;scanf("%d",&x); ed|=x<<(i-1); } for(int x=1;x<=n;++x){ st[x][1]=1<<(x-1); for int tmp = [x]; for(int t=2;t<=2*n;++t){ st[x][t]=st[x][t-1]; if(tmp)st[x][t]|=(1<<(tmp-1)); tmp=fa[tmp]; } } mx=(1<<n)-1; f[0][ed]=1; for(int t=1;t<=2*n;++t){ for(int s=0;s<=mx;++s){ if(!f[t-1][s])continue; for(int i=0;i<=n;++i){ int ns=s^st[i][t]; f [t] [s] = 1; if(!ns){ printf("%d\n",t); return 0; } } } } }