[Comet OJ - Contest #9 & X Round 3] Namid[A]me

Portal


Start reading the wrong question, and thought it was \ (\ sum_ {1 \ Leq U \ Leq v \} Leq the n-f (U, v) \) , also wondering this question as simple as how no one did (

Actually \ (\ sum_ {. 1 \ Leq U \ Leq V \} n-Leq F (U, V) ^ {F (U, V)} \) (Behind his)

This split is almost impossible to do something, it can only be considered directly.

Chain found that for a fixed starting point, is prefixed to the chain \ (\ text {and} \ ) will only operational when certain bits of \ (1 \) becomes \ (0 \) , and therefore a possible \ (\ text {and} \) value of no more than \ (\ log a \) species. I.e., for determining the root of a subtree, the root end of the chain \ (\ text {and} \ ) value of at most \ (d \ log a \) species, where \ (D \) is the number of sub-sub-leaf .

Dfs directly to each point in the subtree maintains its one end a chain \ (\ text {and} \ ) set value and a type number of occurrences. Each time merge two sub-trees, violence calculated to enumerate all the values in two collections. It found that only two leaves will be ready at lca \ (\ log ^ 2a \) complexity, i.e., the total complexity of the combined leaf does not exceed \ (D ^ 2 \ log. 2A ^ \) . Also, because the path up \ (n ^ 2 \) article, \ (Nd \ Leq. 3 \. 6 Times 10 ^ \) becomes a strong nature, \ (O (\ min (n-, D \ log A) ^ 2) \ O Leq (Nd \ log A) \) , in \ (D \) take \ (\ frac {n} { \ log a} \) taken when the equal sign.

However, \ (\ color {grey} { \ text {swk}} \) too dishes, made two errors, will lead to increased complexity \ (O (Nd \ ^ log 2 A) \) :

  • Maintenance subtree one end thereof a chain \ (\ text {and} \ ) when the set type and the number of occurrences of values, for each subtree to a combined weight of type values. \ (\ color {grey} { \ text {swk}} \) using a process deduplication sorted violence. However, two positive vector solution is directly stitched together only at the junction of deduplication. This will not be found on the complexity of the industry to rise.

  • Modulus question plane is the meaning, given for the purpose of the original root by the pretreatment to avoid rapid discrete logarithm power. However, \ (\ color {grey} { \ text {swk}} \) did not notice this point, the power to direct violence quickly QAQ

Fortunately, however, these two \ (\ log a \) belong to a class of small constant, coupled with the data card is full difficult to do, \ (\ Color Gray {} {\ text {SWK}} \) still finished a \ (2999ms \) by the time limit (3s \) \ title feat (escape

Guess you like

Origin www.cnblogs.com/suwakow/p/11419656.html