Under construction

Still being built. Things may change

Signage

Interview

Time limit1sMemory limit128 MB

Summary
Given a sign width, lay out a fixed sentence into lines, justifying each line so spaces are spread as evenly as possible, and print dots for spaces.
Level

Easy3 of 10

Topics
String, Simulation, Implementation, Greedy
Solved
No attempts yet

Problem

The student council at Central Canada Collegiate is putting up signs that show the message WELCOME TO CCC GOOD LUCK TODAY on walls around the school. Each sign is exactly ww characters wide, counting spaces.

The words are laid out on a sign as follows.

  • As many words as possible are placed on the first line, as long as the words separated by single spaces do not exceed ww characters. The first word on a line starts at the leftmost position.
  • When a line holds two or more words, the last word ends at the rightmost position. The leftover spaces are spread across the gaps between the words so that the gaps are as equal as possible; if they cannot all be equal, the larger gaps go on the left.
  • When a line holds only one word, that word starts at the left and the remaining positions on the right are filled with spaces.

Every following line is built the same way, so each line ends up exactly ww characters wide.

Read the width ww and print the finished sign. Print a . character wherever a space would appear.

Constraints

You may assume that w≥7w \ge 7.

Examples2

  1. Example 1

    Input
    15
    
    Expected output
    WELCOME..TO.CCC
    GOOD.LUCK.TODAY
    
  2. Example 2

    Input
    26
    
    Expected output
    WELCOME..TO..CCC.GOOD.LUCK
    TODAY.....................