Permutation Matrix
시간 제한1초메모리 제한512 MB
1부터 2^(2n)까지의 수를 한 번씩 써서 2^n × 2^n 행렬을 만들되, 크기 2^(n-1) × 2^(n-1)인 모든 부분행렬의 합이 같아야 합니다.
문제
You are given a positive integer . Construct such matrix that:
- The matrix contains distinct positive integers from to .
- The sums of elements all each submatrices of size are equal.
A submatrix is a contiguous rectangle of elements in the original matrix.
입력
The first line contains an integer ().
출력
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 lines, with each line containing space-separated integers.