58 analog solution to a problem

A. Divisors

Look question looked for a long time.

Then find the title seems to be mentally retarded.

With a hash table statistics for each factor appeared many times on it.

 

 

 

B. Market

Obviously the article and ask all sort of monotonous pointers do not control time limit.

At first look into the infinite backpack, see the data range silly, $ c = 10 ^ 9 $ matrix can not fast power.

So after violence had not found a sample, and then found to be 01 backpack.

Then nothing positive solution to the difficulty.

Since the pressure does not take into the state, then the weight is pressed into the state.

After taking min, half looking directly on the line.

 

 

 

C. Dash Speed

It is easy to question the meaning of the questions into:

Consider only qualified edge, forming different trees block Unicom, the answer is the maximum diameter of the tree.

So consider how to maintain dynamic tree diameter.

lct cut ah, but does not maintain sub-tree information.

So using segment tree divide and conquer.

The index is a segment tree is the meaning of the questions range in speed.

The number of each edge by $ l $, $ r $ inserted segment tree, there is a $ $ Vector, the modification process section similar indicia permanent.

After the partition process is:

Call $ solve (1, n) $ in the main function,

For $ solve (l, r) $:

The section of the edge $ $ Vector added simultaneously with disjoint-set update diameter / end information and a maximum diameter of each set.

If $ l == r $, the $ ans [l] $ updated to the current maximum diameter.

Call $ solve (l, mid) $, $ solve (mid + 1, r) $.

The edges of $ vector $ deleted.

About the delete operation,

Rank by merger, consolidation changes each time the amount is relatively small, with a stack maintenance undo it.

Guess you like

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