Analog Test 49

T1:

  Meaning of the questions:

    Seeking the modulo interval maximum value.

  answer:

    My thoughts cleared somewhat odd.

    Standard calculation block, a preprocessing block for all the maximum value of each modulo K, and then find to block violent.

    Time complexity $ O (N \ sqrt {N \ ln N}) $

    My idea is for K Points.

    When K <= 50, st table with violence to find, open 50 because the memory is really not enough .

    In other cases, the search violence in all its forms, such as $ [aK, (a + 1 ) K) $ interval, Chairman of the trees dfs find the maximum range, need pruning .

    If the complex (shu) Miscellaneous (ju) degrees (hen) excellent (shui) show, then it may be the AC.

    Time complexity $ O (Nlog_2N \ sqrt {N}) $

T2:

  Meaning of the questions:

    There are N points within the coordinate system, find the number of fold lines meet the following conditions, to 1e9 + 7 mod.

    For point (x1, y1) through a fold line, (x2, y2) ...... (xk, yk).

    $\forall j \in (1,k] \  y_j < y_{j-1}$

    $\forall j \in (2,k] \  x_{j-2} < x_j < x_{j-1}  \  or \  x_{j-1} < x_j < x_{j-2}$

  Solution:
    consider for the x DP, all points will now be sorted in accordance with x.

    Number provided dp [i] [0/1] is present in the i-th point, the next fold line left / right extension program.

    From left to right enumerate all the points, and then reverse the previous enumeration.

    And before all the current node can be greater than its ordinate point even edges.

      $dp[j][1]+=dp[i][0] \ (y_j > y_i)$

    Until all the ordinate points smaller than the current node, and it can be connected even side edge.

      $dp[i][0]+=dp[j][1] \ (y_j < y_i)$

    Because the bottom-up horizontal axis span is increasing, so to ensure the correctness of the reverse enumerate the second dimension.

    Time complexity $ O (N ^ 2) $

T3:

  Meaning of the questions:

    0/1 to a matrix, initially there is a there is an all-zero matrix, each may be any number of communication 0/1 staining four blocks communication, minimum required number of times after the operation can yield the target matrix.

  answer:

    First of all, the dyeing process is reversible, so we can go back dyeing process.

    Then consider how best stained.

    We set the number of border from one point to 0/1 point through which all of the maximum number of layers.

    So every time a layer is to eliminate staining only the best, so Unicom block to make stained maximized.

    After dyeing once each, the point minus a number of layers, dyeing continues until the number of layers is up to 0, then the matrix must contain all 0s.

    The number of layers of different points may be different, so we find the minimum number of layers, is the answer.

    Enumeration each point to begin the deque BFS From this point, if the boundary through 0/1, the distance 1, from the tail into the team, the team from the queue head and vice versa.

    The maximum distance to each point is the number of layers.

    Note: Since the initial state is all 0, but not all 1, the BFS after all points from 1 to plus 1, in the maximum value.

    The number of layers of different points of the minimum value is the answer.

    Time complexity $ O (n ^ 4) $

Guess you like

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