Educational Codeforces Round 66
F
The meaning of problems: a sequence of length n, the number of required intervals \ ([L, R & lt] \) , so that it constitutes a 1 ~ r-l + 1 arrangement. \ (n \ le 3 * 10 ^ 5, a_i \ le n \)
key: random weights
Legal certainty interval includes 1, and the maximum length is. Consider the case of the maximum value of a right, each one can enumerate the right to record the maximum x, case, check \ ([r-x + 1 , r] \) of this section whether a permutation. Similarly in the case of maximum 1 left.
Consider hash: 1 for each of the random number n ~ a weight of 64, is defined as \ (H_i \) , arranged so that a length of k hash must be \ (h_1 \ xor \ h_2 \ dots \ xor \ h_k \) , so it can be O (1) check, so complexity is O (n).