#P11787. 「FAOI-R4」蒲公英的约定

    ID: 11241 远端评测题 4000ms 512MiB 尝试: 0 已通过: 0 难度: 7 上传者: 标签>模拟树形数据结构线性数据结构2025洛谷原创O2优化洛谷月赛

「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 ζ\zeta found the admission statistics of some year to fill out high school applications better.

To be specific, there were nn students. The ii-th of them filled out lil_i aspirations, i.e., chose lil_i schools. The jj-th aspiration of the ii-th student was ai,ja_{i,j}. Among the mm senior high schools participating in the admission process, the ii-th school offered tit_i quotas.

Let bib_i be the number of students already determined to be admitted to school ii. The following process was adopted to determine the admission statistics for each individual:

  • All the remaining students with the highest score o\bm o in the entrance exam whose admission result hadn't been determined were selected.
  • Let SS be the set of schools with available quotas. Formally, S={1imti>bi}S = \{1 \leq i \leq m \mid t_i > b_i\}.
  • For each selected student xx, iterate ii over their list of aspirations ax,1,ax,2,,ax,lxa_{x,1}, a_{x, 2}, \ldots, a_{x, l_x} in order:
    • if iSi \in S, then student xx was admitted by school ii. Then, bibi+1b_i \gets b_i + 1 and the process was terminated.
    • If none of the schools in ax,1,ax,2,,ax,lxa_{x, 1}, a_{x, 2}, \ldots, a_{x, l_x} belonged to SS, student xx was not admitted to any school.
  • The changes of bib_i during the third step did not affect the set SS. Therefore, it's possible for some schools to have bi>tib_i > t_i. 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, qq modifications are made. Each modification is described by two integers xx and vv. It reduces txt_x by vv. 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 nn, mm, and qq, denoting the number of students, schools, and modifications.

The second line of input contains mm integers t1,,tmt_1, \ldots, t_m.

Then nn lines follow. The ii-th line describes the aspiration list of the ii-th student: there is an integer lil_i followed by li+1l_i + 1 integers ai,1,ai,2,,ai,lia_{i,1}, a_{i,2}, \ldots, a_{i, l_i}, and oio_i. oio_i denotes the score of student ii in the entrance exam.

Then qq lines follow. Each line consists of two integers x,vx, v, representing a modification.

Output Format

Output qq lines. The ii-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:

  • {1,2,3,3,3}\{1, 2, 3, 3, 3\};
  • {1,2,3,3,3}\{1, 2, 3, 3, 3\};
  • {1,2,3,3,3}\{1, 2, 3, 3, 3\};
  • {1,2,3,2,0}\{1, 2, 3, 2, 0\};
  • {1,0,2,2,0}\{1, 0, 2, 2, 0\}, and
  • {0,0,1,0,0}\{0, 0, 1, 0, 0\}, respectively, in which 00 represents being not admitted.

Constraints

  • 1n,m,q31051 \leq n, m, q \leq 3 \cdot 10^5
  • 0ti1060 \leq t_i \leq 10^6
  • 0lim0 \leq l_i \leq m, lim\sum l_i \leq m
  • 1ai,jm1 \leq a_{i,j} \leq m (For each ii, It's not guaranteed that ai,ja_{i,j} are distinct)
  • 0oi1060 \leq o_i \leq 10^6
  • 1xm1 \leq x \leq m
  • 1vtx1 \leq v \leq t_x, where txt_x is the value of txt_x at the time exactly before the modification

Subtasks

Subtasks are used in this problem.

  • Subtask 1 (15 pts): max(n,m,q)500\max(n, m, q) \leq 500, li5000\sum l_i \leq 5000
  • Subtask 2 (20 pts): There are at most 22 distinct values in oo.
  • Subtask 3 (35 pts): oio_i are distinct.
  • Subtask 4 (30 pts): No additional constraints.