#P4113. [HEOI2012] 采花
[HEOI2012] 采花
Description
Xiao Xun'er is the princess of an ancient kingdom, and one of her hobbies is picking flowers.
Today the weather is fine and sunny, so the princess went to the newly built palace garden in the morning to pick flowers.
The garden is large enough to hold flowers in total, with colors labeled by integers . The flowers are arranged in a single row to make it convenient for the princess to pick. After each picking session, the princess counts how many different colors she has collected; the more colors, the happier she is. At the same time, she has a quirk: she does not allow that, among the flowers she finally picks, any color appears only once. For this reason, every time she picks a flower, either she has already picked a flower of that color before, or her accurate intuition tells her she will be able to pick that color again.
Due to time constraints, the princess can only walk through one continuous segment of the garden to pick flowers, so the maid Fuhan Jie arranged trips after considering various factors. For each trip, you are asked how many different colors the princess can collect.
Input Format
The first line contains three space-separated integers, representing the number of flowers , the number of colors , and the number of trips .
The second line contains space-separated integers. The -th integer is the color of the -th flower.
From line to line , each line contains two integers . On line , the numbers represent that the -th trip covers flowers from the -th to the -th.
Output Format
Output lines, one integer per line. The integer on the -th line is the number of different colors the princess can collect on the -th trip.
5 3 5
1 2 2 3 1
1 5
1 2
2 2
2 3
3 5
2
0
0
1
0
Hint
Explanation for Sample 1:
There are five flowers, and their colors are .
For the first trip, the picking interval is . She can pick the flowers at positions , so there are two different colors, and .
For the second trip, the picking interval is , but the flowers of colors and each appear only once, so the princess cannot pick any flower.
For the third trip, the picking interval is , but color appears only once, so the princess cannot pick any flower.
For the fourth trip, the picking interval is . She can pick the flowers at positions , and there is only one color, .
For the fifth trip, the picking interval is , but colors each appear only once, so the princess cannot pick any flower.
Constraints:
This problem uses bundled multi-test-point evaluation and has two subtasks.
For subtask (worth points), it is guaranteed that .
For subtask (worth points), it is guaranteed that .
For all test points, it is guaranteed that , .
Translated by ChatGPT 5
京公网安备 11011102002149号