#P16461. [UOI 2026] Lazy Student

    ID: 16446 Type: RemoteJudge 1000ms 512MiB Tried: 0 Accepted: 0 Difficulty: 7 Uploaded By: Tags>贪心2026UOI(乌克兰)

[UOI 2026] Lazy Student

题目描述

Kozak Vus is a student at a university. In the first semester, he has nn subjects and mm weeks of study ahead of him. Vus knows all the assignments in advance, and for convenience he has estimated their difficulty. He made a table of size n×mn \times m, where for the ii-th subject in the jj-th week he has to complete an assignment of difficulty ai,ja_{i, j}. Note that all difficulty values are pairwise distinct\textbf{pairwise distinct} across the entire table.

Vus calls the difficulty of a week\textit{difficulty of a week} the total difficulty of the assignments from all subjects in that week.

Vus did not get enough vacation to rest, so he wants to avoid working too hard, at least at the beginning of the semester. Fortunately, this year students were allowed to adjust their study plan. Vus can perform the following operation at most kk times: choose a subject ii and two different weeks j1j_1 and j2j_2, then swap the assignments of this subject. Thus, in the table, the values ai,j1a_{i, j_1} and ai,j2a_{i, j_2} exchange places.

Vus's goal is to make the difficulty of the first week as small as possible. If there are several such ways, he wants to minimize the difficulty of the second week. If there are still several ways, he wants to minimize the difficulty of the third week, and so on.

More formally, let bjb_j be the difficulty of the jj-th week:

bj=a1,j+a2,j++an,jb_j = a_{1, j} + a_{2, j} + \dots + a_{n, j}

Kozak Vus wants to apply no more than kk operations so that the resulting array of weekly difficulties B=[b1,b2,,bm]B = [b_1, b_2, \dots, b_m] becomes lexicographically minimal. Help him find this array.

输入格式

The first line contains three integers nn, mm, kk (1n,m10001 \le n, m \le 1000, 0k1090 \le k \le 10^9) --- the number of rows, the number of columns, and the maximum number of operations.

The next nn lines contain mm integers each, ai,ja_{i,j} (1ai,j1061 \le a_{i,j} \le 10^6, all numbers ai,ja_{i,j} are pairwise distinct) --- the initial table.

输出格式

Print mm integers --- the lexicographically smallest array of column sums that can be obtained after no more than kk operations.

3 3 1
7 1 3
6 8 4
5 2 9
12 17 16
3 4 2
9 1 7 4
2 8 3 10
5 6 11 12
8 18 21 31

提示

For the first sample:

Since k=1k = 1, at most one operation can be performed.

The initial column sums are:

7+6+5=187 + 6 + 5 = 18,

1+8+2=111 + 8 + 2 = 11,

3+4+9=163 + 4 + 9 = 16.

So the initial sum array is [18,11,16][18, 11, 16].

To obtain the lexicographically smallest array, it is best to perform an operation in the first row and swap the numbers 77 and 11.

After that, the table will look like this:

first row: 1 7 31\ 7\ 3,

second row: 6 8 46\ 8\ 4,

third row: 5 2 95\ 2\ 9.

The column sums are:

1+6+5=121 + 6 + 5 = 12,

7+8+2=177 + 8 + 2 = 17,

3+4+9=163 + 4 + 9 = 16.

The resulting array [12,17,16][12, 17, 16] is lexicographically smallest among all variants that can be obtained with one operation.

For the second sample:

The initial column sums are:

9+2+5=169 + 2 + 5 = 16,

1+8+6=151 + 8 + 6 = 15,

7+3+11=217 + 3 + 11 = 21,

4+10+12=264 + 10 + 12 = 26.

The initial sum array is [16,15,21,26][16, 15, 21, 26].

Perform an operation in the first row and swap the numbers 99 and 11, then perform a second operation and swap the numbers 99 and 44 also in the first row. Then we obtain the following table:

1 4 7 91\ 4\ 7\ 9

2 8 3 102\ 8\ 3\ 10

5 6 11 125\ 6\ 11\ 12

The column sums are [8,18,21,31][8, 18, 21, 31].

Scoring

  • (33 points): k=nmk=n\cdot m;
  • (55 points): k=1k=1, n=1n=1;
  • (1111 points): n=1n=1;
  • (1313 points): the elements in the rows are initially sorted in descending order;
  • (1616 points): k10k \le 10;
  • (1111 points): m=2m=2;
  • (1616 points): n,m100n, m \le 100;
  • (2525 points): no additional constraints.