20200223 (ABC) solution to a problem by Liushao Rui Yang Chen Yi

 A:
Given a graph, and only a drawing ring, each output node of the distance ring.
The DFS first pass, all access points and recording mark depth, if the access point has been marked, the point and the point of its parent node on the ring, are denoted as u, v
of the second pass the DFS, v from the trigger, inverse depth has access to u, all the points on this path is the ring
for the third time BFS, all points on the ring distance scale is 0, and one by one as the starting point be BFS, find other points came from
 
 B:
not difficult to find, the following conditions can eat only temporary Queen Queen i J
R & lt [i] = R & lt [J]
C [i] = C [J]
R & lt [i] + C [i] = R & lt [J] C + [J]
R & lt [I] - C [I] R & lt + n = [J] - C [J] + n (where + n order to avoid negative numbers)
recorded at each row / column / diagonal parallel Queen to both ends of the leftmost and rightmost position Queen, for each of the queen, determines whether the current line eaten on a line / column / diagonal line parallel to, the number of statistics.
I.e., a record of all r [i] / r [i ] + c [i] / r [i] - c [i] + n same Queen c [i] is the maximum / minimum value, the recording of all c [i] the same Queen of r [i] is the maximum / minimum value.
Time complexity of O (n-)

C:
similar to find the largest sub-matrix approach.
First find a prefix and, by sum1 [i] [j] denotes the stars number of the j-th column of the prefix and that
sum1 [i] [j] = sum1 [i - 1] [j] + star [i] [j ]
wherein Star [i] [j] denotes the i-th row j-th column if there stars
enumeration vertical boundary u / d, while the right border enumeration i, to find the left boundary of the number larger than the number of stars within the region can make the K's.
Specifically enumeration u / d while maintaining a longer prefix and sum2, with sum2 [I] represents the (u, 1) to (d, i) the number of stars in the range, since, as long as we find small sum2 equal to sum2 [i] - k number of values on the line.
Since the prefix and incremental, can binary search.
Time complexity of O (n ^ 3logn)

Guess you like

Origin www.cnblogs.com/QLU-ACM/p/12358987.html