Logo
(追記) (追記ここまで)

27351번 - Gardening 서브태스크스페셜 저지다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
0.2 초 1024 MB43171440.000%

문제

Azusa, the witch of the highlands, wants to do a fun activity with her friend Laika: gardening. They want to make a rectangular garden $N$ meters tall by $M$ meters wide. The garden is divided into 1 meter by 1 meter squares. The question is: what flowers should they plant?

Laika has found $K$ different types of flowers. Azusa and Laika will plant one type of flower in each 1 meter by 1 meter square. Furthermore, for aesthetic reasons, the garden must satisfy the following constraints:

  1. Each flower type must appear at least once in the garden.
  2. For any two squares where the same flower type is planted, a path between them where all the intermediate squares have the same type of flower must exist. For example, the following gardens are not allowed:
  1. Any square must have exactly two adjacent squares planted with the same type of flower. For example, the following gardens are not allowed:

Note that, in the previous constraints, two squares are “adjacent” if and only if they share a common edge (not merely a corner); and a path is a sequence of adjacent squares.

You are given $T$ different values for $N,ドル $M$ and $K$. Help Azusa and Laika create gardens that satisfy the conditions for each test case — or, tell them that it is impossible to do this.

입력

The first line of the input contains the integer $T$. Afterwards, $T$ lines follow, each describing a test case. Each test case consists of three integers $N,ドル $M$ and $K$.

출력

Output the answers for each test case in order. For a test case, if no solution exists, output NO on a single line. Otherwise, first output YES on a single line, and then output $N \times M$ integers arranged in $N$ lines and $M$ columns describing the required garden. The lines and columns of the output correspond to the lines and columns of the garden, with each integer corresponding to a 1 meter by 1 meter square. The integers represent the types of flowers planted in the squares, where the types are indexed from 1ドル$ to $K$. If there are multiple correct solutions you may output any of them.

제한

  • 1ドル ≤ N, M ≤ 200,000円$.
  • 1ドル ≤ K ≤ N \times M$.
  • Let $S$ equal the sum of $N \times M$ for all the test cases in a file for which an answer exists (i.e. where the output is not NO).
  • $S ≤ 200,000円$.

서브태스크

번호배점제한
15

$N, M ≤ 4$

26

$N ≤ 4$

310

$N ≤ 6$

418

$N = M$

539

$K$ is chosen uniformly at random between 1ドル$ and $N \times M$

622

No further restrictions

예제 입력 1

5
2 2 2
2 2 1
4 4 4
4 4 2
4 6 3

예제 출력 1

NO
YES
1 1
1 1
YES
1 1 2 2
1 1 2 2
3 3 4 4
3 3 4 4
YES
1 1 1 1
1 2 2 1
1 2 2 1
1 1 1 1
YES
1 1 1 1 1 1
1 2 2 3 3 1
1 2 2 3 3 1
1 1 1 1 1 1

힌트

For the first test case, we note that no 2 by 2 garden with 2 types of flowers is possible. Thus we output NO. The other gardens are pictured below:

출처

Olympiad > Romanian Master of Informatics > Romanian Master of Informatics 2021 1번

채점 및 기타 정보

  • 예제는 채점하지 않는다.
(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /