Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- make two array dp_max[u],dp_min[u].
- 1. dp_max[u]=x means if current player is in node u and he can take the xth largest number in the subtree of u.(the current player always want the 1th largest number)
- 2. dp_min[u]=x means if current player is in node u and he can take the xth largest number in the subtree of u.(the current player always want the (siz)th largest number)(siz means the size of subtree of u)
- 3. dp_max[u]=min(dp_min(v)) (v is child of u)
- 4. dp_min[u]=sigma(dp_max(v)-1)+1
- it seems "4" is not easy to get .
- just think this way, suppose the current player is in node u, and for all its child v ,dp_max[v] has been got,just regard it as a constant ,because we are going to use tree dp, so its child can get through recursive. The player wants to make dp_min[u] as large as possible, so for every child he can fill the top largest number(1,2,3...) in the space to make the Opponent can never get it , so that the number he put into the "unsafe" space is as large as possible! we call the space is "safe" when the player can never get it. for every child v , its safe place is dp_max[v]-1 !
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement