#P10300. [THUWC 2020] 工资分配

[THUWC 2020] 工资分配

Problem Description

At the end of the month, the boss of a company prepares a salary distribution plan for the kk employees in the company (they are numbered 1k1 \sim k). This plan can be represented by a sequence aa of length kk, where aia_i denotes the salary of the ii-th person. Now, this plan is placed on the desk in the office, unattended.

Some employees decide to replace this salary distribution plan so that they can get more salary. So, some employees prepare a forged plan bb (also a sequence of length kk) that will not be noticed by the boss, and choose a moment to sneak into the office. He will peek at the plan aa^{'} that is currently on the desk. If this employee’s index is ii and bi>aib_i > a^{'}_i, then he will replace the entire plan with bb. To ensure the replacement succeeds, an employee may sneak into the office at multiple moments, and may forge different plans. However, at any single moment, at most one employee sneaks into the office.

Assume there are nn moments in one day when employees sneak into the office. We number these moments from 11 to nn in time order. Now, you are given, for each moment tt, the employee ptp_t who sneaks in and the forged plan btb_t he brings at time tt. You are also given qq queries; each query provides the boss’s initial plan. Please compute the final plan left on the desk.

Input Format

The first line contains three integers nn, qq, kk, denoting the number of moments, the number of queries, and the number of employees.

The next nn lines each contain k+1k+1 integers pt,bt,1,,btkp_t, b_{t,1}, \cdots, b_{t_k}, denoting the employee who sneaks in at time tt and the plan he prepares.

The next qq lines each contain kk integers a1,,aka_1, \cdots, a_k, denoting the boss’s initial plan.

Output Format

Output qq lines. Each line contains kk integers, denoting the final plan.

5 10 3
1 7 2 5
2 1 4 10
3 2 6 3
1 8 1 4
2 7 3 5
4 7 8
2 2 6
9 10 6
9 3 4
8 1 6
10 6 10
4 9 2
4 1 10
7 7 8
10 3 2

7 3 5
7 3 5
9 10 6
7 3 5
7 3 5
10 6 10
7 3 5
7 3 5
7 3 5
7 3 5

Hint

Subtasks

There is 20%20\% of the testdata with n,q1,000n, q \le 1{,}000.

There is another 10%10\% of the testdata with k=1k = 1.

For all testdata, n,q105n, q \le 10^5, k20k \le 20.

Notes

The input and output size of this problem is large. It is recommended to use scanf/printf for I/O. If you use cin/cout, it is recommended to add std::ios::sync_with_stdio(0); std::cin.tie(0); std::cout.tie(0); at the beginning of the main function.

Translated by ChatGPT 5