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

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

Balanced Illumination

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

요약
n비트의 순환 그레이 코드를 만들어, 이웃한 조합이 한 비트만 다르고 각 전구가 거의 같은 횟수로 토글되도록 2^n개 조합을 출력한다.
난이도

보통10점 중 6점

유형
비트 연산, 조합론, 구현
정답자
아직 제출이 없습니다

문제

Saint Bitsburg government is preparing a technical requirement for New Year city decoration.

The governor thinks that there should be a garland of nn lights on the main square. The lights will turn on and off and entertain the residents of Saint Bitsburg.

The chief designer decided that the garland would change its appearance each second. Every light in the garland can be in two states: on and off. Each second exactly one light will change its state from on to off, or from off to on. Also the chief designer wants all combination of lights in the garland to repeat with a period 2n2^n seconds. During the period of 2n2^n seconds all 2n2^n possible lights combinations in the garland have to be presented.

The city's chief engineer, however, noted that frequently turning lights on and off would cause their malfunction. To minimize the chance of the lights malfunction it is required for every light to be turned on and off approximately the same number of times.

So, the final technical requirement for you --- Chief Programmer of the Government Department of Information Technology --- is here.

  • You need to make a plan of 2n2^n combinations of lights a_0,a_1,…,a_2n−1a\_0, a\_1, \ldots, a\_{2^n-1}, where a_ka\_k is a line of nn zeros and ones, a_k\[i]=1a\_k\[i]=1 means, that the light ii in the combination a_ka\_k is on, a_k\[i]=0a\_k\[i]=0 means, that the light ii in the combination a_ka\_k is off. 
  • All combinations in the plan have to be distinct.
  • This plan will be launched in a cycle, each second the next combination is presented on the garland, in the tt-th second the combination a_t, mod ,2na\_{t\\,\bmod\\,2^n} is presented.
  • Adjacent combinations have to differ in exactly one light's state. Combination a_2n−1a\_{2^n-1} and a_0a\_0 also have to differ in exactly one light's state.
  • Let us denote by c_ic\_i the number of state changes of the light ii during a complete cycle, including the final change from a_2n−1a\_{2^n-1} to a_0a\_0. Then for any i≠ji \ne j values c_ic\_i and c_jc\_j have to differ by no more than 22.

Get to work!

입력

Input contains one integer nn (1≤n≤171 \le n \le 17).

출력

Output 2n2^n lines of nn characters --- sequence of combinations in the plan. It is guaranteed that a plan satisfying all requirements exists.

힌트

In the first sample test c_1=c_2=2c\_1=c\_2=2, c_3=4c\_3=4.

In the second sample test c_1=c_2=c_3=c_4=4c\_1=c\_2=c\_3=c\_4=4.

예제2

  1. 예제 1

    입력
    3
    
    예상 출력
    000
    010
    011
    111
    110
    100
    101
    001
    
  2. 예제 2

    입력
    4
    
    예상 출력
    0000
    0010
    1010
    1011
    0011
    0111
    0110
    0100
    0101
    0001
    1001
    1101
    1111
    1110
    1100
    1000