10 provincial election simulation solution to a problem

A. Food Chain

dp topologically sequence.

 

B. selected point game

Required to support merge two trees, and at the same time maintaining maximum independent set tree.

Consider special circumstances, each time only plus point of maximum a label, the problem is a simple dynamic dp.

Offline form the final tree, consider the addition of a leaf node, the node updates the information on the light chain 1 can be a node.

In fact, I thought of this, a dynamic dp approach has obviously, but still did not think the exam.

Still maintain the original shape of the tree.

The two operations are combined every block Unicom, a father and son is combined.

In fact as long as the update information of the child node to the parent node of the parent node until the communication with the path of the light chain ancestor block it.

Because each of the heavy chain of a top chain, the end of the chain is varied, a feasible approach is to use disjoint-set maintenance information of each heavy chain.

 

C. Random

Record some interesting things:

1. $ n $ sizes in $ [1, n] is a desired minimum $ between random variables.

The minimum value of $ X $ into not less than the minimum $ i $ (1 <= i <= x) the probability sum.

The question then is converted to 0/1 variable, $ a $ 0/1 n-variables, each with a probability of p, where 1 is the probability that both $ p ^ n $.

Of course, the minimum value is calculated directly by $ X $ another embodiment several approaches are possible.

2. The number to obtain the number of random screening methods.

For each number of $ X $, the condition is any one selected divisor are not selected, so the number of the desired contribution is $ \ frac {1} {d (x)} $.

Guess you like

Origin www.cnblogs.com/skyh/p/12241200.html