#P7873. 「SWTR-7」Scores(easy version)

「SWTR-7」Scores(easy version)

Background

This problem is the easy version of Scores. Note that the constraints are different from the hard version.

Please pay attention to the special time and memory limits. A simplified statement is provided below the description.

Problem Description

There are nn students in Little A's class. They recently took an exam with mm subjects. The score of student ii in subject jj is an integer si,j (0si,j100)s_{i,j}\ (0\leq s_{i,j}\leq 100). For student ii, if there exists another student jj such that student ii's score in every subject is not greater than student jj's score, then student ii will feel upset.

The Mid-Autumn Festival is coming. Kind Little A does not want any classmate to feel upset, so he decides to hack the school's management system and modify everyone’s scores. Before doing such a risky thing, Little A wants to know whether he can achieve his goal. However, since there are too many students and subjects, he asks you to help construct a valid solution.

If there exists a score table where no student feels upset, output YES\texttt{YES} first, and then output any score table that satisfies the requirement; otherwise output NO\texttt{NO}.


"Simplified Statement"

Try to construct an n×mn\times m matrix ss such that all elements are integers in [0,100][0,100], and for any i,j (ij)i,j\ (i\neq j) there exists a kk such that si,k>sj,ks_{i,k}>s_{j,k}.

Input Format

This problem has multiple test cases.

The first line contains an integer tt, indicating the test point ID.
The second line contains an integer TT, indicating the number of test cases.

For each test case:
One line contains two integers n,mn,m.

Output Format

For each test case:

If Little A's requirement cannot be achieved, output one line containing the string NO\texttt{NO}.
Otherwise, output one line containing the string YES\texttt{YES}, then output nn lines, each containing mm integers separated by spaces. The jj-th number on line i+1i+1 represents si,js_{i,j}.

0
4
5 3
1 10
17 1
2 7
YES
100 99 97
98 100 99
95 97 100
0 98 100
99 99 99
YES
1 2 3 4 5 6 7 8 9 10
NO
YES
95 99 76 88 87 51 49
72 100 80 92 100 60 60

Hint

"Special Judge"

This problem uses Special Judge. Please read the output format carefully. Wrong output format may lead to UKE.

The SPJ will first check whether your first line matches the correct answer.
If it matches and the answer is YES\texttt{YES}, the SPJ will then check whether your output satisfies Little A's requirement:

  • 0si,j1000\leq s_{i,j}\leq 100 and si,js_{i,j} is an integer.
  • Each student has at least one subject in which their score is higher than another student.

If a solution exists and you output YES\texttt{YES} but your construction is wrong, you will get 50%50\% of the score for that test point.

"Constraints and Notes"

This problem has 6 test points.

  • Testcase #0 (1 point): the sample.
  • Testcase #1 (10 points): n=1n=1.
  • Testcase #2 (10 points): m=1m=1.
  • Testcase #3 (20 points): m=2m=2.
  • Testcase #4 (30 points): nmn\leq m.
  • Testcase #5 (29 points): no special constraints.

For 100%100\% of the testdata, 1n,m1001\leq n,m\leq 100, T=20T=20 (except Testcase #0).
For all test points, time limit is 200 ms, memory limit is 16 MB.

"Source"

Sweet Round 07 A1.
idea & solution & data: Alex_Wei; validation: chenxia25.

Translated by ChatGPT 5