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

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

Cubic Path

시간 제한2초메모리 제한256 MB

요약
n차원 큐브에서 서로 다른 점들을 지나며, 부분집합으로 더 짧은 경로를 만들 수 없는 가장 긴 완전 경로를 찾는다.
난이도

보통10점 중 7점

유형
그래프, 완전 탐색, 백트래킹
정답자
아직 제출이 없습니다

문제

A path in the nn-dimensional set 0,1n\\{0, 1\\}^n is a sequence of nn-dimensional points x_1,x_2,…,x_k∈0,1nx\_1, x\_2, \ldots, x\_k \in \\{0, 1\\}^n such that, for each ii (1≤i≤k−11 \le i \le k - 1), points x_ix\_i and x_i+1x\_{i + 1} differ in exactly one coordinate, and all the points x_1,…,x_kx\_1, \ldots, x\_k are distinct. The length of the path x_1,…,x_kx\_1, \ldots, x\_k is kk.

A path  x_1,…,x_kx\_1, \ldots, x\_k is imperfect if there exists a shorter path y_1,…,y_ℓy\_1, \ldots, y\_{\ell} which leads from the first to the last point of this path and consists of a subset of the same points. In other words, y_1,…,y_ℓ⊆x_1,…,x_k\\{y\_1, \ldots, y\_{\ell}\\} \subseteq \\{x\_1, \ldots, x\_k\\}, x_1=y_1x\_1 = y\_1, x_k=y_ℓx\_k = y\_{\ell} and ℓ<k\ell < k. If a path is not imperfect, it is perfect.

Your task is to find the longest perfect path in the set 0,1n\\{0, 1\\}^n.

입력

The only line contains a single integer nn (1≤n≤61 \le n \le 6).

출력

On the first line, print LL, the length of the path. On the next LL lines, print the description of the path x_1,…,x_Lx\_1, \ldots, x\_L: ii-th of these lines must contain nn characters (zeroes and ones) describing the point x_ix\_i.

It is easy to see that there are multiple longest perfect paths. Print any one of them.

예제3

  1. 예제 1

    입력
    2
    
    예상 출력
    3
    00
    01
    11
    
  2. 예제 2

    입력
    3
    
    예상 출력
    5
    000
    001
    011
    111
    110
    
  3. 예제 3

    입력
    4
    
    예상 출력
    8
    0000
    0001
    0011
    0111
    0110
    1110
    1100
    1101