#P2058. [NOIP 2016 普及组] 海港
[NOIP 2016 普及组] 海港
Description
Xiao K is a customs officer at a harbor. Many ships arrive at the harbor every day, and there are usually many passengers on board from different countries.
Xiao K is very interested in these ships that arrive at the harbor. He records every ship in chronological order. For the -th arriving ship, he records its arrival time (in seconds), the number of passengers , and the nationality of each passenger .
Xiao K has collected information about ships. Please help him compute, for each ship’s arrival time, how many distinct countries the passengers come from among all ships that arrived within the last hours ( hours seconds), up to and including that time.
Formally, you need to compute values. For the -th output, consider all ships satisfying . Among all in these ships, count how many distinct values there are.
Input Format
The first line contains a positive integer , indicating that Xiao K recorded information about ships.
Each of the next lines describes one ship: the first two integers and denote the ship’s arrival time and the number of passengers on board, followed by integers , which are the nationalities of the passengers.
It is guaranteed that the are nondecreasing, measured in seconds. Counting from when Xiao K first started working, the -th ship arrives at second .
It is guaranteed that , , , .
Here, denotes the sum of all .
Output Format
Output lines. On the -th line, output one integer: the required statistic after the -th ship arrives.
3
1 4 4 1 2 2
2 2 2 3
10 1 3
3
4
4
4
1 4 1 2 2 3
3 2 2 3
86401 2 3 4
86402 1 5
3
3
3
4
Hint
Sample Explanation 1:
The first ship arrives at second . The ships that arrived in the last hours are just the first ship, with passengers from countries , for a total of distinct countries.
The second ship arrives at second . The ships that arrived in the last hours are the first and second ships, with passengers from countries , for a total of distinct countries.
The third ship arrives at second . The ships that arrived in the last hours are the first, second, and third ships, with passengers from countries , for a total of distinct countries.
Sample Explanation 2:
The first ship arrives at second . The ships that arrived in the last hours are just the first ship, with passengers from countries , for a total of distinct countries.
The second ship arrives at second . The ships that arrived in the last hours are the first and second ships, with passengers from countries , for a total of distinct countries.
The third ship arrives at second . The ships that arrived in the last hours are the second and third ships, with passengers from countries , for a total of distinct countries.
The fourth ship arrives at second . The ships that arrived in the last hours are the second, third, and fourth ships, with passengers from countries , for a total of distinct countries.
Constraints
- For of the test points, $n = 1, \sum k_i \leq 10, 1 \leq x_{i,j} \leq 10, 1 \leq t_i \leq 10$.
- For of the test points, $1 \leq n \leq 10, \sum k_i \leq 100, 1 \leq x_{i,j} \leq 100, 1 \leq t_i \leq 32767$.
- For of the test points, $1 \leq n \leq 100, \sum k_i \leq 100, 1 \leq x_{i,j} \leq 100, 1 \leq t_i \leq 86400$.
- For of the test points, $1 \leq n \leq 1000, \sum k_i \leq 3000, 1 \leq x_{i,j} \leq 1000, 1 \leq t_i \leq 10^9$.
- For of the test points, $1 \leq n \leq 10^5, \sum k_i \leq 3 \times 10^5, 1 \leq x_{i,j} \leq 10^5, 1 \leq t_i \leq 10^9$.
Translated by ChatGPT 5
京公网安备 11011102002149号