41 provincial election simulation solution to a problem

A. To a change of name

Apparently half an answer, and then if there is a problem into a set of perfectly matching bipartite graphs.

It is then found if a sequence number of the sub-string is longer than n-$ $, then there is no need of even edges.

Each string so the construction of no more than $ $ n-edges, and then run a network flow on the bin.

 

B. Dynamic half plane cross

Because too much food, so only do this with a few routine questions.

$ $ LCM is easy to find the index to take $ \ $ max for each quality factor.

So consider the depth of the lower standard, maintaining a monotonous stack.

The stack is then monotonically differential operation represented by each change.

Then the complexity of this issue in the trees is not correct, it put forward a dsu get away.

Now and then found monotonous stack is not inserted in the tail, so the need to put forward a set to maintain this monotonous stack.

The segment tree persistent look, you can answer the inquiries online.

Thinking positive solution of the case.

Consider the $ p ^ k $ this stuff into a $ k $ th article, wherein the weight of each item is $ p $.

The question then is given $ u, d $, asking $ u $ subtree weight product is no more than $ d $ items.

The thing about the chain directly set and maintain the line.

Conventional ideas are from sub-tree to his father's transfer, then you need to limit the $ d $ this thing is very troublesome.

Then practice here is in accordance with the depth of the transfer from small to large, and then the tree line at $ dfs $ labeled sequence, so direct access to the largest tree line where the depth to get away.

 

C. to obtain places

Obviously the answer is $ 1- \ prod \ limits_ {i = l} ^ r 1- \ frac {a_i} {x} $.

To avoid precision, to each of the first a_i $ $ $ X $ are each remove a $ \ max (a_i) $. 

Consider put to the back of a multiplicative take $ ln $, and then converted to a simple summation of the form.

But still with $ x $-related forms, no way to directly engage.

So the whole Taylor expansion, maintenance factor $ x ^ k \ (k \ leq 30) $, and then calculate it.

Then found that the operation of taking $ LN $ $ $ a_i particularly large, it will lead to a large absolute value $ ln (1- \ frac {a_i} {x}) $ this number, then the accuracy gone.

However, this number is not easy to find a lot, because accuracy is only required to $ 10 ^ {- 6} $, if such a number can be directly out of the lot.

Consider the definition of a threshold value of $ 0.5 * x $, if $ a_i> 0.5 * x $, calculates the number of such violence, or directly by Taylor expansion.

Because it is static, so the entire ST table out, and then follow the most direct value of divide and conquer like, if the current number of precision is enough, directly out of divide and conquer.

Then find because every time to find the best values ​​are double precision, complexity is clearly no more than two of the $ log $.

Guess you like

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