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

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

Word Ladder

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

요약
길이가 같은 서로 다른 n개의 단어를 사다리 순서로 나열하되, 첫 단어에서 마지막 단어까지 최단 경로가 모든 단어를 쓰도록 만든다.
난이도

보통10점 중 7점

유형
그래프, BFS, 최단 경로, 구현
정답자
아직 제출이 없습니다

문제

You and Alice are solving word ladder puzzles. A word ladder is a sequence of words, all with the same number of letters, where each word in the sequence differs from the previous word by a single letter.

Because you are better at creating word ladders than at solving them, you have decided to devise a very specific puzzle for Alice. You will give Alice a list of nn words. Then, she will construct a word ladder from your word list. Alice must start from the first word in your list, and modify one letter at a time to obtain the last word in your list. Each intermediate word Alice uses must also be from your word list.

Alice is so good at solving word ladder puzzles that she always produces the shortest word ladder possible. You want to force Alice to use all nn words in her word ladder. There should be no way to construct a shorter word ladder from the starting word to the ending word using the words in your word list.

Create a list of nn words, such that the shortest word ladder from the first word to the last word uses all the words in the list. Because you need to verify the word ladder solution before giving the puzzle to Alice, the word list should be given in word ladder order.

입력

The single line of input contains a single integer nn (3≤n≤5,0003 \le n \le 5\\,000), which is the length of the word list (and solution word ladder) you must construct for Alice.

출력

Output nn lines. Each line contains a single word of length at most 1010 letters. The words must all be distinct, of the same length, and consist only of lowercase letters. Note that for this problem, a word is simply a string of lowercase letters; it does not have to be an English word.

The list of nn words should be printed in word ladder order, such that each word differs from the previous word by a single letter. There should exist no shorter word ladder from the first word to the last word using fewer than nn words from the list.

It can be proven that an answer exists for all nn satisfying the input constraint. Any answer satisfying these requirements will be considered correct.

예제2

  1. 예제 1

    입력
    5
    
    예상 출력
    lead
    load
    toad
    told
    gold
    
  2. 예제 2

    입력
    3
    
    예상 출력
    aa
    ab
    bb