#P9247. [集训队互测 2018] 完美的队列
[集训队互测 2018] 完美的队列
Problem Description
Xiao D has std::queue<int> objects, numbered from to .
Xiao D has a different level of liking for each queue. If a queue that he does not like much uses too much memory, Xiao D will be unhappy.
More specifically, if the size() of the -th queue is greater than , Xiao D will keep calling pop() on this queue until its size() becomes less than or equal to .
Now all these queues are empty. Xiao D thinks this is too boring, so he decides to perform some operations.
Each operation can be described by l r x, meaning that for all queues with indices in , perform push(x). Of course, after each operation ends, Xiao D will use the method mentioned above to prevent these queues from using too much memory.
Xiao D's queues are magical, so he can perform each operation in time.
He believes everyone else's queues can do it too, so Xiao D made this problem to give everyone easy points.
To prove that you really performed these operations, after each operation you need to output the number of distinct values that are still present in the queues.
Input Format
The first line contains two positive integers , representing the number of queues and the number of operations.
The second line contains positive integers, where the -th one is .
The next lines each contain three positive integers l r x, where the -th line describes the -th operation.
Output Format
Output lines in total. Each line contains one non-negative integer, representing the number of distinct values across all queues after the -th operation ends.
3 3
1 2 3
1 2 1
2 3 2
1 3 3
1
2
2
Hint
Sample Explanation
After the first operation, the queues become , and the values still in the queues are , so there is distinct value.
After the second operation, the queues become , and the values still in the queues are , so there are distinct values.
After the third operation, the queues become , and the values still in the queues are , so there are distinct values.
Constraints
For all data, , and .
There are test points in total, each worth points. The -th test point satisfies .
In particular, the following test points satisfy some special properties:
Test point : ;
Test point : ;
Test point : ;
Test point : ;
Test points : .
For each test point, you must pass all testdata that meets the constraints and properties of that point to obtain the score for that point.
Translated by ChatGPT 5