#P9731. [CEOI 2023] Balance

    ID: 10946 远端评测题 2000ms 1024MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>2023Special JudgeO2优化CEOI(中欧)

[CEOI 2023] Balance

Background

Translated from CEOI 2023 Day 1 T3 Balance.

Problem Description

Due to a hacker attack on the judging servers, the organizers decided to rejudge all submissions.

There are NN judging machines and TT problems (numbered 1,2,,T1, 2, \cdots, T). The organizers have already decided which submissions each machine will judge (each machine has the same number of submissions, namely SS submissions; it is guaranteed that SS is an integer power of 22). During the next SS minutes, in each minute, each judging machine will judge one submission.

Each submission belongs to some problem. Since the machine that stores the data is too fragile, it is required that, for every problem and for any two moments in time, the difference between the numbers of submissions judged for that problem at those two moments does not exceed 11.

Please construct a schedule that satisfies the above condition.

Input Format

The first line contains N,S,TN, S, T.

The next NN lines each contain SS integers, representing the problem IDs of the submissions assigned to this judging machine.

Output Format

Output NN lines, each with SS numbers, representing the problem IDs of the submissions that this judging machine should judge in order.

It can be proven that a solution always exists.

3 2 3
1 2
2 3
2 3
2 1
3 2
2 3
3 4 3
2 3 2 2
2 3 3 2
2 2 3 2
2 2 2 3
3 2 3 2
2 3 2 2

Hint

It is guaranteed that there exists a positive integer kk such that S=2kS = 2 ^ k. Also, 1N,S,T1051 \le N, S, T \le 10 ^ 5, and NS5×105NS \le 5 \times 10 ^ 5.

  • Subtask 1 (1010 points): S=2S = 2 and N,T20N, T \le 20.
  • Subtask 2 (15+5+515 + 5 + 5 points): S=2S = 2.
  • Subtask 3 (15+5+515 + 5 + 5 points): NS104NS \le 10 ^ 4.
  • Subtask 4 (20+10+1020 + 10 + 10 points): no other constraints.

For the last three subtasks, partial scores exist (corresponding to the points in parentheses):

  • The first number is the score you can get if you can solve all testdata satisfying TNT \le N and, for each problem, the number of submissions is divisible by SS.
  • The second number is the additional score you can get if you can solve all testdata satisfying TNT \le N.
  • The third number is the additional score you can get if you solve the whole Subtask.

On Luogu, this problem is split into 1010 subtasks. For the original last three subtasks, in this problem they are each split into three subtasks in order (for example, the original Subtask 3 becomes subtasks 5,6,75, 6, 7), and they have dependencies.

Translated by ChatGPT 5