Do the problem too little, everything to see the puzzle.
Test instructions only give a traitor, then he must be the leaf node (worst case), then the "lead rebel" point must constitute a chain.
F[u] means that u do not take the lead in the smallest of rebellions, then consider each of its sons V, (not rebel) F[v], (Rebellion) size[v]/(size[u]-1), here take a min.
Because it is the worst case, I take Max for all my sons.
Now consider how the answer is structured (this I've been thinking about for a long time), for STD Ans=max (ans,f[u]) (size[u]>k),
The necessity of pre-certification: Obviously, each tree size greater than k, we can not fill, ans at least to reach F[u].
Re-sufficiency: we just asked each subtree of size greater than K. Perhaps the choice in their f[u] is illegal, but it does not affect the answer; Moreover, the subtree that first reached K must not lead the rebellion, so it does not need to be transferred again. So strictly speaking of a certain question of the STD also less a word "has been marked", just do not know why can. (Maybe not to write is right, involved in a bunch of inequalities, I can't testify anyway)
#include <cstdio>#include<algorithm>#defineEPS 1e-8#defineN 1000010using namespacestd;intedgenum,n,k;intVet[n],head[n],size[n],son[n],next[n];DoubleF[n];Doubleans=0;voidAddintUintv) {Edgenum++;vet[edgenum]=v;next[edgenum]=head[u];head[u]=Edgenum;}voidDfsintu) { inte=head[u];size[u]=1; son[u]=0; while(e>0){ intv=Vet[e]; DFS (v); Son[u]+=size[v];size[u]+=Size[v]; E=Next[e]; } e=head[u];if(e==0) {F[u]=1.0; if(size[u]>k) ans=Max (Ans,f[u]); return; } while(e>0){ intv=Vet[e]; if(size[v]>k) {E=next[e];Continue;}///////////that ' s it!F[u]=max (F[u],min (F[V),1.0*size[v]/(size[u]-1))); E=Next[e]; } if(size[u]>j) {ans=Max (Ans,f[u]); }}intMain () {scanf ("%d%d",&n,&K); for(intI=2; i<=n;i++){ intX;SCANF ("%d",&x); Add (x,i); } DFS (1); printf ("%.10LF", ans);}bzoj4726
[bzoj4726] Sabota