#P12606. 碰碰车大战

    ID: 11658 远端评测题 400ms 512MiB 尝试: 2 已通过: 1 难度: 6 上传者: 标签>洛谷原创Special Judge构造洛谷月赛

碰碰车大战

Description

You are given integers nn, mm, and kk.

Your task is to construct kk tuples (xi,1,xi,2,,xi,m)(x_{i,1},x_{i,2},\dots,x_{i,m}) of size mm that satisfy the conditions below:

  • xi,jx_{i,j} is an integer in [1,n][1,n];
  • For any two tuples, after removing an element from the same position in both tuples, the resulting tuples (which have size m1m-1) are not equal. In other words, there still exists at least one position at which the remaining elements differ.

Formally, you need to satisfy:

  • $\forall 1\le i\le k,1\le j\le m,x_{i,j}\in [1,n] \cap \mathbb{Z^+}$;
  • $\forall 1\le i<j\le k,1\le p\le m,\exists 1\le l\le m,l\neq p,x_{i,l}\neq x_{j,l}$.

Input Format

The first line contains three integers nn, mm, and kk.

Output Format

Print kk lines. Each line should contain mm integers — the jj-th integer in the ii-th line represents xi,jx_{i,j}.

3 3 3
1 2 1
2 1 2
3 3 3

Hint

This problem involves a large output size, so I/O optimization is recommended.

The problem uses subtask dependencies: failing a prerequisite subtask will result in a score of zero for any subtask.

It is guaranteed that for all testcases, $1\le n\le 10^9,2\le m\le 10^5,1\le k \le n^{m-1},k\times m\le 10^6$。

# nn mm kk Points Depends On
11 109\le 10^9 =2=2 n\le n 1010 -
22 105\le 10^5 55 11
33 10\le 10 =3=3 - 2020 -
44 10\le 10
55 104\le 10^4 100\le 100 - 3,43,4
66 109\le 10^9 105\le 10^5 2525 151\sim 5