#B4127. Knowledge Level Rearrangement
Knowledge Level Rearrangement
Knowledge Level Rearrangement
A class of students is arranged in an grid. The student in the -th row (from the front) and -th column (from the left) has a knowledge level .
In a single adjustment process, the teacher does the following:
- Compute the sum of knowledge levels for each column. Identify all columns whose sum is equal to the maximum or the minimum among all column sums.
- All students in these identified columns leave their seats and line up in the corridor ordered by their knowledge levels in descending order.
- The evacuated students then sit back in the empty seats following a snake-like order: filling the grid row by row, where in odd-numbered rows (1-indexed) seats are filled from left to right, and in even-numbered rows from right to left.
Given the initial seating arrangement and an integer $k$, perform the adjustment process $k$ times and output the final seating arrangement.
inputFormat
The input consists of multiple lines:
- The first line contains three integers $n$, $m$, and $k$ ($1\le n, m\le 100$, $0\le k\le 1000$) — the number of rows, columns, and the number of adjustments to perform.
- Each of the next $n$ lines contains $m$ integers, where the $j$-th integer in the $i$-th line represents $a_{i,j}$, the knowledge level of the student at row $i$ and column $j$.
outputFormat
Output the final seating arrangement after adjustments. Each of the lines should contain integers separated by a space.
sample
3 3 1
3 1 2
2 4 1
5 3 3
5 1 3
2 4 3
2 3 1
</p>