#P11570. 「chaynOI R1 T3」镍铬合金机器人
「chaynOI R1 T3」镍铬合金机器人
Background

Problem Description
You are given a sequence of length .
There are queries. Each query gives three numbers . For each query, find how many intervals (with ) starting at satisfy $\text{mex}(\{bot_l, bot_{l+1}, \cdots, bot_r\}) \in [x, y]$.
Note: For a multiset , the function is defined as the smallest non-negative integer that does not appear in . For example, .
Input Format
The first line contains two positive integers , representing the length of the sequence and the number of queries.
The second line contains numbers, representing the sequence .
The next lines each contain three integers .
Output Format
Output lines in total. Each line contains one integer, representing the answer.
4 2
0 1 3 2
1 2 2
2 1 4
2
0
10 10
0 0 1 1 1 0 0 1 0 1
1 0 0
2 0 1
3 1 2
4 0 1
5 0 2
6 0 1
7 1 1
8 2 2
9 0 0
10 1 2
0
1
5
2
6
2
1
2
0
0
Hint
For of the data, , , , .
This problem uses bundled testdata.
- Subtask 1 (10 pts): .
- Subtask 2 (15 pts): .
- Subtask 3 (15 pts): .
- Subtask 4 (20 pts): .
- Subtask 5 (40 pts): No special constraints.
Translated by ChatGPT 5