#P11787. Parallel Volunteer Admission Simulation
Parallel Volunteer Admission Simulation
Parallel Volunteer Admission Simulation
In city B, the admission process for the high‐school entrance exam has become increasingly diversified. In this problem, you are required to simulate the admission process under the principle of parallel volunteer admission. The simulation works as follows:
- There are \( n \) students. The \( i\)-th student submits \( l_i \) preferences in order, denoted by \( a_{i,1}, a_{i,2}, \dots, a_{i,l_i} \), where each \( a_{i,j} \) is the ID of a school.
- There are also \( m \) schools. The \( i\)-th school has \( t_i \) admission slots.
- The acceptances are determined by repeatedly performing the following process until every student’s result is fixed (students are considered in descending order of exam score, i.e. the first student in input has the highest score):
- Find the highest scored student whose admission result is not yet determined.
- Let the set of schools with available slots be \( S = \{ i \mid 1 \le i \le m,\ t_i > b_i \} \) where \( b_i \) is the current number of admitted students at school \( i \).
- The selected student \( x \) considers his/her choices in order. For each choice \( i = a_{x,1}, a_{x,2}, \dots, a_{x,l_x} \):
- If \( i \in S \) (i.e. \( b_i < t_i \)), then \( x \) is admitted to school \( i \) and \( b_i \) is incremented by 1. The process for student \( x \) ends immediately.
- If none of the choices can be admitted, student \( x \) is not admitted by any school.
- Note that any change in \( b_i \) during the admission of the current student does not affect the set \( S \) for that student. In other words, even if a school \( i \) ends up with \( b_i > t_i \), its admission decision remains fixed.
After the admissions process is completed, there will be several queries. For each query of the form x v
, you must permanently update the quota of school \( x \) as follows: \( t_x \leftarrow t_x - v \), and then output the number of students whose admission result differs from the previous result.
Note: The students are given in the order of decreasing exam scores (i.e. the first student has the highest score).
inputFormat
The first line contains three integers \( n \), \( m \), and \( q \), representing the number of students, schools, and queries respectively.
The next \( n \) lines each describe a student. Each line begins with an integer \( l_i \) (the number of preferences submitted by student \( i \)) followed by \( l_i \) integers \( a_{i,1}, a_{i,2}, \dots, a_{i,l_i} \) indicating the school IDs in order of preference.
The next line contains \( m \) integers \( t_1, t_2, \dots, t_m \) representing the initial number of admission slots for each school.
Each of the following \( q \) lines contains two integers \( x \) and \( v \). For each query, the quota of school \( x \) is permanently decreased by \( v \) (i.e. \( t_x \leftarrow t_x - v \)).
outputFormat
For each query, output a single integer on a separate line indicating the number of students whose admission result changes after re-simulating the admission process with the updated quotas.
sample
3 2 1
2 1 2
1 1
2 2 1
1 2
2 1
0