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

18537번 - Associativity Degree 스페셜 저지다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
6 초 512 MB1000.000%

문제

Consider a binary operation ◦ defined on numbers 1 through n:

◦ : {1, . . . , n} × {1, . . . , n} → {1, . . . , n}.

Let us define its associativity degree as the number of triplets i, j, k ∈ {1, . . . , n} for which ◦ is associative:

i ◦ (j ◦ k) = (i ◦ j) ◦ k.

Your task is, given n and k, to construct an operation ◦ such that its associativity degree is exactly k.

입력

The first line of input contains two integers n and q (1 ≤ n ≤ 64, 1 ≤ q · n2 ≤ 106).

The i-th of the next q lines contains a single integer ki (0 ≤ ki ≤ n3).

It is guaranteed that all ki are distinct.

출력

For each given value of ki, do the following:

If there is no operation ◦ with associativity degree ki for given n, output “NO” on a single line.

Otherwise, output “YES” on the first line, followed by n lines containing n integers each. The j-th integer in the i-th line must be equal to i ◦ j.

제한

예제 입력 1

3 1
27

예제 출력 1

YES
1 1 1
1 2 3
1 3 2

예제 입력 2

1 2
0
1

예제 출력 2

NO
YES
1

노트

The operation from the first sample can be concisely described as i ◦ j = 1 + ((i − 1) · (j − 1)) mod 3, and it is fully associative.

출처

Camp > Petrozavodsk Programming Camp > Winter 2019 > Day 7: Oleksandr Kulkov Contest 1, Botan Investment Cup B번

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

출처

대학교 대회

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

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