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

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

ReWord-wrap

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

요약
주어진 텍스트를 단어를 자르지 않고 각 줄이 w자를 넘지 않도록 탐욕적으로 줄바꿈하고, 데이터셋마다 빈 줄을 하나 출력합니다.
난이도

보통10점 중 4점

유형
문자열, 구현
정답자
아직 제출이 없습니다

문제

When a window of a text editor resizes, it is often necessary to readjust all of the containing words to fit in the screen window without splitting up any of the words. This is referred to as word-wrapping. Given a block of text, word-wrap the data to fit in a specific size.

입력

The first line of input will contain a single integer n that indicates the number of datasets to follow. Each dataset will consist of:

  • An integer w indicating the number of characters to word wrap, where 10 ≤ w ≤ 50.
  • An integer m indicating the number of lines of text input that are to be word wrapped, where 1 ≤ m ≤ 100.
  • The m lines of text to be word wrapped.

출력

Output the text word wrapped to the proper number of characters, and include one blank line after each dataset.

예제1

  1. 예제 1

    입력
    2
    40
    4
    Chinua Achebe was born on November 16, 1930 into the Igbo
    African ethnic group in southern Nigeria. He was raised in a
    Christian family, but he was always fascinated by the
    traditional African religion and culture.
    35
    4
    Achebe uses the short story of a hard working man
    in a war torn area with a bright outlook on life to act
    as a model for other Africans affected by
    the Nigerian Civil War.
    
    예상 출력
    Chinua Achebe was born on November 16,
    1930 into the Igbo African ethnic group
    in southern Nigeria. He was raised in a
    Christian family, but he was always
    fascinated by the traditional African
    religion and culture.
    
    Achebe uses the short story of a
    hard working man in a war torn area
    with a bright outlook on life to
    act as a model for other Africans
    affected by the Nigerian Civil War.