#P5070. [Ynoi Easy Round 2015] 即便看不到未来

[Ynoi Easy Round 2015] 即便看不到未来

Description

Ke Duoli gives you a sequence. For each query, you need to count, in a given interval, the number of maximal consecutive value-range segments of lengths 1,2,,101,2,\ldots,10.

A consecutive value-range segment is defined as follows:

  • Sort all numbers in the interval and remove duplicates. Let the resulting sequence be bb.
  • For a pair (l,r)(l,r), if every number in bl,bl+1,,brb_l,b_{l+1},\ldots,b_r is equal to the previous number +1+1.
  • And for the pairs (l,r+1)(l,r+1) and (l1,r)(l-1,r), neither satisfies the condition above, then we call (l,r)(l,r) a maximal consecutive value-range segment, with length rl+1r-l+1.

Input Format

The first line contains two integers n,mn,m, representing the length of the sequence and the number of queries.

The next line contains nn integers representing the sequence.

Then follow mm lines, each containing two integers l,rl,r, representing the query interval.

Output Format

For each query, output a string of length 1010. The ii-th character represents the number of maximal consecutive segments of length ii modulo 1010.

8 9
2 3 3 3 3 6 6 6
1 8
2 3
4 5
6 8
1 2
3 4
5 6
3 8
5 5
1100000000
1000000000
1000000000
1000000000
0100000000
1000000000
2000000000
2000000000
1000000000

Hint

Idea: nzhtl1477, Solution: nzhtl1477, Code: mcfx, Data: nzhtl1477.

For 100%100\% of the testdata, 1n,m,ai1061\leq n,m,a_i\leq10^6, 1lrn1\leq l\leq r\leq n.

Translated by ChatGPT 5