#P7809. [JRKSJ R2] 01 序列
[JRKSJ R2] 01 序列
Description
You are given a sequence of length . Then there are queries of two types:
1 l r: query the length of the longest non-decreasing subsequence in the interval from to .2 l r: query the length of the longest increasing subsequence in the interval from to .
Input Format
The input contains lines.
Line contains two positive integers .
Line contains numbers or , representing the sequence .
The next lines each contain three positive integers describing one query, in the format above.
Output Format
Output lines.
For each query, compute the answer and output it.
8 4
0 1 1 0 1 0 0 1
1 1 8
2 1 8
1 3 6
2 5 6
5
2
2
1
Hint
This problem uses bundled testdata.
| Special Property | Score | |||
|---|---|---|---|---|
| All are equal | ||||
| None | ||||
| hack testdata | ||||
For of the testdata, , , and .
The input and output size is extremely large, so please use fast I/O methods.
Sample Explanation:
For the first query, valid sequences include and .
For the second query, valid sequences include .
For the third query, valid sequences include , , and .
For the fourth query, valid sequences include and .
: Added two sets of hack testdata.
Translated by ChatGPT 5
京公网安备 11011102002149号