#P11787. 「FAOI-R4」蒲公英的约定
「FAOI-R4」蒲公英的约定
Description
As senior high schools in City B are gradually diversifying their student recruitment method, the number of unified enrollment quotas decreases year after year. In this problem, you are asked to track the process based on the "Parallel Aspiration" rules, which will be explained below.
Little found the admission statistics of some year to fill out high school applications better.
To be specific, there were students. The -th of them filled out aspirations, i.e., chose schools. The -th aspiration of the -th student was . Among the senior high schools participating in the admission process, the -th school offered quotas.
Let be the number of students already determined to be admitted to school . The following process was adopted to determine the admission statistics for each individual:
- All the remaining students with the highest score in the entrance exam whose admission result hadn't been determined were selected.
- Let be the set of schools with available quotas. Formally, .
- For each selected student , iterate over their list of aspirations in order:
- if , then student was admitted by school . Then, and the process was terminated.
- If none of the schools in belonged to , student was not admitted to any school.
- The changes of during the third step did not affect the set . Therefore, it's possible for some schools to have . Once the admission decision is made for a student, their status is final, whether they are admitted or not.
- Repeat this process until the status of all students are final.
Because the initial statistics have several errors, modifications are made. Each modification is described by two integers and . It reduces by . You need to determine the number of students whose admission result is changed from when the last modification was made. Note that the modifications are persistent, which means a previous modification keeps in effect.
Input Format
The first line of input contains three integers , , and , denoting the number of students, schools, and modifications.
The second line of input contains integers .
Then lines follow. The -th line describes the aspiration list of the -th student: there is an integer followed by integers , and . denotes the score of student in the entrance exam.
Then lines follow. Each line consists of two integers , representing a modification.
Output Format
Output lines. The -th line contains an integer, as the number of students whose admission result is changed from when the last modification was made.
5 3 5
1 2 5
3 1 2 3 3
3 1 2 3 2
3 3 2 1 5
2 3 2 4
1 3 4
3 1
3 2
3 1
3 1
2 2
0
0
2
2
3
Hint
The admission results of each student after each modification are:
- ;
- ;
- ;
- ;
- , and
- , respectively, in which represents being not admitted.
Constraints
- ,
- (For each , It's not guaranteed that are distinct)
- , where is the value of at the time exactly before the modification
Subtasks
Subtasks are used in this problem.
- Subtask 1 (15 pts): ,
- Subtask 2 (20 pts): There are at most distinct values in .
- Subtask 3 (35 pts): are distinct.
- Subtask 4 (30 pts): No additional constraints.
京公网安备 11011102002149号