HDU 4035Maze (tree + probability dp, Absolute Classic)

Source: Internet
Author: User

Test instructions

Give you n nodes of the tree, starting from 1 nodes, to each node has three cases, was killed back to 1 nodes, to find a hidden exit, along the adjacent edge of the current node to the next node, given the probability of three cases each node is Ki,ei,1-ki-ei, Expected to find the number of edges that have already been exported.

Analysis:

Use a tree-like DP to consider the problem. When a node is a leaf node it simply goes to the parent node, and the non-leaf node can go to the Father node and all child nodes.

EI represents the expectation that the I-node passes through the number of edges

Then leaf node: ei=ki*e1+ (1-ki-ei) * (e[par[i]]+1);//par[i] represents the Father node of I

Non-leaf node: ei=ki*e1+ (1-ki-ei) * (E[par[i]]/m+sum (e[son[i])/m+1)//m represents the number of edges connected to the I node, Son[i] represents the I node child

Next up is the processing ring.

Make ei=ai*e1+bi*e[par[i]]+ci;

HDU 4035Maze (tree + probability dp, Absolute Classic)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.