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

23482번 - Matrix Inversion 스페셜 저지다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 (추가 시간 없음) 1024 MB10000.000%

문제

You have an $N$ by $N$ grid board, which is initially empty. You will write an integer to each cell, using each integer from 1ドル$ to $N^2$ exactly once. Let $M_{i,j}$ be the integer written on the cell in the $i$-th row from the top and the $j$-th column from the left.

Let's define sequences $A$ and $B$ as follows:

  • $A = M_{1,1}, M_{1,2}, \dots, M_{1,N}, M_{2,1}, M_{2,2}, \dots, M_{2,N}, \dots, M_{N,N}$
  • $B = M_{1,1}, M_{2,1}, \dots, M_{N,1}, M_{1,2}, M_{2,2}, \dots, M_{N,2}, \dots, M_{N,N}$

For example, when the board looks like this,

1 3 4
2 7 6
9 8 5

$A$ and $B$ are defined as follows.

  • $A = 1,3,4,2,7,6,9,8,5$
  • $B = 1,2,9,3,7,8,4,6,5$

You are given integers $N, X, Y$. Find a way to fill in the cells so that the inversion numbers of $A$ and $B$ are $X$ and $Y$ respectively, or report that it is impossible to do so.

Note: an inversion number of a sequence $C = c_1, c_2, \dots, c_{N \times N}$ is the number of pairs $(i, j)$ s.t. both $i < j$ and $c_i > c_j$ are satisfied.

입력

Input is given from Standard Input in the following format:

$N$ $X$ $Y$

출력

If there is no solution, print 'No'.

Otherwise, print the answer in the following format:

Yes

$M_{1,1}$ $M_{1,2}$ $\dots$ $M_{1,N}$

$M_{2,1}$ $M_{2,2}$ $\dots$ $M_{2,N}$

$\vdots$

$M_{N,1}$ $M_{N,2}$ $\dots$ $M_{N,N}$

If there are multiple solutions, you can print any of them.

제한

  • 2ドル \leq N \leq 300$
  • 0ドル \leq X, Y \leq \frac{N^2(N^2 - 1)}{2}$

예제 입력 1

3 8 13

예제 출력 1

Yes
1 3 4
2 7 6
9 8 5

힌트

출처

Contest > Open Cup > 2019/2020 Season > Stage 15: Grand Prix of Tokyo G번

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

출처

대학교 대회

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

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