Simulation Test 54

T1:
  All prime number is not in the same set of constant.

  Disjoint-set to maintain the set where each number is the number of chain consolidation. 

  But this complexity is $ O (n ^ 2) $ a.

  Consider optimization, the two numbers are not prime to have the same quality factor means that between them, the decomposition of the quality factor for each number, and you can merge his prime factors.

  Line after sieve smallest prime factors can $ O (logn) $ find all prime factors.  

  Time complexity $ O (nlogn) $.

T2:

  Pressure considerations like, provided the array $ dp [i] [j] $, $ I $ represents elapsed paths, the path through state $ J $ situation exists or not.

  Time complexity $ O (nm2 ^ d) $, needs to be optimized.

  Binary search, the first half of the first DP, DP again after half an enumeration intermediate point and up to fight.

  Time complexity $ O (nm2 ^ {d / 2} + n2 ^ d) $

T3:

  Correct answer is a big simulation.

  The displacement between the dots as the line segment, then all meet $ x_i = x_ {i-1} $ or $ x_ {i-1} <x_i <x_ {i + 1} $ or $ x_ {i-1 }> x_i> x_ {i + 1} $ point can be deleted.

  Maintenance is not a list of points to be deleted.

  The displacement of each segment of the process out, pressed into the stack, the off-line sorting all inquiries, from small to large enumeration, each current line segment length is less than the length of throw, the combined upper and lower two line segments, the first sentence should Laid .

  However, many of the details is not very good writing.

  Time complexity $ O (nlogn) $

Guess you like

Origin www.cnblogs.com/hz-Rockstar/p/11619476.html