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

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

Cows on Parade

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

요약
길이 S인 모든 흑백 소 순열이 parade 안에 연속한 부분열로 한 번씩 나타나도록 N마리의 소 순서를 정해 출력한다.
난이도

보통10점 중 7점

유형
그래프, DFS, 비트 연산, 조합론
정답자
아직 제출이 없습니다

문제

Farmer John was marching 19 of his finest black Angus and white Jersey cows to market the other day when his wife, Farmeress Joanne, noticed that all 16 possible combinations of four successive black and white cows (e.g., bbbb, bbbw, bbwb, bbww, ..., wwww) were present (as contiguous cow-subsequences) as the parade passed by. Of course, some of the combinations overlapped others.

Your job is to find an ordering of N cows so that each of the possible sequences of C colors can be found as a contiguous 'subsequence' of cows. Typical lengths and subsequences are: 2,5; 3,10; 4,19; 5,36 and others. Each input dataset is guaranteed to have a solution.

입력

A single line with two integers:

  • N, 1 ≤ N ≤ 32782, the number of cows on parade
  • S, 1 ≤ S ≤ 15, the length of the subsequence

출력

The output is N lines, each with a single 'b' or 'w'. The lines represent a possible ordering of the parading cows.

예제1

  1. 예제 1

    입력
    10 3
    
    예상 출력
    b
    b
    b
    w
    b
    w
    w
    w
    b
    b