아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Permutation Matrix

시간 제한1초메모리 제한512 MB

요약
1부터 2^(2n)까지의 수를 한 번씩 써서 2^n × 2^n 행렬을 만들되, 크기 2^(n-1) × 2^(n-1)인 모든 부분행렬의 합이 같아야 합니다.
난이도

보통10점 중 6점

유형
분할 정복, 재귀, 수학, 행렬
정답자
아직 제출이 없습니다

문제

You are given a positive integer nn. Construct such matrix 2n×2n2^n \times 2^n that:

  • The matrix contains distinct positive integers from 11 to 22n2^{2n}.
  • The sums of elements all each submatrices of size 2n−1×2n−12^{n-1} \times 2^{n-1} are equal.

A submatrix is a contiguous rectangle of elements in the original matrix.

입력

The first line contains an integer nn (1≤n≤101 \le n \le 10).

출력

On the very first line, print "YES" if the answer exists, or "NO" if not.

If the answer exists, print any such matrix on the next 2n2^n lines, with each line containing 2n2^n space-separated integers.

예제1

  1. 예제 1

    입력
    1
    
    예상 출력
    NO