#P7873. Non-Dominated Score Matrix Construction

    ID: 21058 Type: Default 1000ms 256MiB

Non-Dominated Score Matrix Construction

Non-Dominated Score Matrix Construction

You are given two integers \(n\) and \(m\) representing the number of students and subjects, respectively. Your task is to modify the score table by constructing an \(n \times m\) matrix \(s\) with each element being an integer in the range \([0, 100]\). The matrix must satisfy the following condition: for any two distinct students \(i\) and \(j\), there exists at least one subject \(k\) (\(1 \le k \le m\)) such that \(s_{i,k} > s_{j,k}\) (and, by symmetry, also a subject where \(s_{j,k} > s_{i,k}\)).

This guarantees that no student is completely dominated by another in all subjects. If such a matrix exists, output "YES" followed by the matrix (each row in one separate line, numbers separated by spaces). Otherwise, output "NO".

Note: A valid construction always produces a set of \(n\) distinct score vectors such that for every pair \(i\ne j\), the two vectors are not comparable in all coordinates. One way to achieve this is to select vectors from an antichain in \(\{0, 100\}^m\). In fact, if we choose the vectors having exactly \(L = \lfloor\frac{m}{2}\rfloor\) subjects with score 100 and the rest 0, they form an antichain. However, by Sperner's theorem this antichain can have at most \(\binom{m}{L}\) elements. Thus, a necessary and sufficient condition for the existence of a valid score table is \(n \le \binom{m}{\lfloor m/2 \rfloor}\).

The task is to either construct such a matrix or determine that it is impossible.

inputFormat

The input consists of a single line containing two space-separated integers \(n\) and \(m\) \( (1 \le n, m \le 10^5 \) in general, though practical limits are imposed by the combinatorial constraint explained above).

outputFormat

If a valid \(n\times m\) matrix exists, output "YES" on the first line, followed by \(n\) lines each containing \(m\) space-separated integers (each integer between 0 and 100 inclusive) representing the score table. If no valid score table exists, output "NO".

sample

2 2
YES

0 100 100 0

</p>