#P7577. 「PMOI-3」简单模拟题
「PMOI-3」简单模拟题
Description
You are given a sequence of length .
There are queries. Each query is in the form a b c d e f, and you need to compute the value of the following expression:
Here, denotes the number of distinct values in the subarray of sequence , and denotes the number of distinct values among .
Input Format
The first line contains two integers , representing the length of the sequence and the number of queries.
The second line contains integers, where the -th integer represents .
The next lines each contain integers . Let the answer to the previous query be (in particular, if this is the first query, then ). Then in this query:
Note that you need to reorder so that .
Output Format
For each query, output the answer in order.
3 1
2020 2021 2020
3 3 2 2 1 1
1
10 3
2 2 4 3 5 3 5 4 1 2
3 5 2 4 1 2
5 7 2 9 2 4
1 3 1 8 1 3
2
4
4
Hint
[Sample 1 Explanation]
In the first query, .
It is easy to get , and , so the answer is .
[Sample 2 Explanation]
| Query ID | ||||||
|---|---|---|---|---|---|---|
| ① | 3 | 4 | 5 | 6 | 1 | 2 |
| ② | 2 | 5 | 8 | 10 | 2 | 4 |
| ③ | 3 | 6 | 8 | 1 | 3 | |
[Constraints]
This problem uses bundled testdata.
- Subtask 1 (10 pts): , .
- Subtask 2 (15 pts): .
- Subtask 3 (20 pts): .
- Subtask 4 (25 pts): .
- Subtask 5 (30 pts): no special constraints.
For of the testdata, , . For all queries, , .
[Hint]
-
In this problem, indicates whether is . If it is in this interval, the value is ; otherwise it is .
-
The input size is large, so please use a faster input method.
Translated by ChatGPT 5
京公网安备 11011102002149号