#P10300. Salary Distribution Replacement
Salary Distribution Replacement
Salary Distribution Replacement
At the end of the month, a company boss prepares a salary distribution plan for k employees numbered $1\sim k$. The plan is represented by a sequence $a=[a_1,a_2,\dots,a_k]$, where $a_i$ is the salary of employee $i$. The plan is left unsupervised on the office desk.
Some employees decide to increase their own salary by replacing the plan. Each such employee prepares a forged plan $b=[b_1, b_2, \dots, b_k]$ that will not be detected by the boss. At various time instants in a day (numbered $1,2,\dots,n$), an employee sneakily enters the office. When an employee with index $p_t$ enters at time $t$, they first observe the current plan $a'$ on the desk. If their own salary in the forged plan, i.e. $b_{t,p_t}$, is strictly greater than the current salary $a'_{p_t}$, then they replace the entire plan with their forged plan $b_t$. Note that an employee might attempt this replacement multiple times (and even with different forged plans) during the day. At any time instant, at most one employee enters the office.
You are given the details of the $n$ replacement attempts: for each time $t$, you know the employee index $p_t$ and the forged distribution $b_t$. Then, there are $q$ queries. In each query, an initial boss plan $a$ (of length $k$) is provided. Your task is to determine the final salary plan on the desk after all the replacement attempts are processed in order.
Note: For any employee $i$, the check is done as follows: if $b_{t,i} > a'_{i}$ where $i = p_t$, then the complete plan is replaced by $b_t$.
inputFormat
The first line contains three integers k, n, and q --- the number of employees, the number of replacement attempts, and the number of queries, respectively.
Then, there are n lines, each describing a replacement attempt. The t-th of these lines contains an integer $p_t$ (the employee index who attempts the replacement) followed by k integers $b_{t,1}, b_{t,2}, \dots, b_{t,k}$ representing the forged salary plan $b_t$.
After that, there are q lines. Each of these lines contains k integers representing the boss's initial plan $a=[a_1,a_2,\dots,a_k]$ for that query.
outputFormat
For each query, output the final salary distribution plan (i.e. k space-separated integers) on a separate line after processing all n replacement attempts in order.
sample
3 3 2
2 5 4 3
1 6 1 2
3 3 4 7
4 4 4
6 3 4
3 4 7
3 4 7
</p>