UberOA #13
Newspaper Page LEFT/RIGHT Alignment
估计简单可在线判题
考点(AI 标注)字符串模拟/实现
Each paragraph has a LEFT or RIGHT alignment tag. In the original order, greedily pack as many entries as possible into each line, putting one space between entries and never splitting an entry. The leftover space in a line goes on the right (LEFT) or on the left (RIGHT). Each line of the outer frame is width+2 wide; the top and bottom lines are all *, each content line has one * at each end, and no extra padding is added. Entries containing spaces, such as "Please look" in the original example, are kept as whole entries.
This site's standard input/output is stated explicitly.
输入格式
The first line contains width P; each paragraph starts with a line align wordCount, followed by wordCount lines, each with one entry. 5≤width≤100, 1≤P≤50. This site uses 1..100 entries per paragraph, each of length 1..width, made of visible ASCII characters and internal spaces, with no leading or trailing spaces.
输出格式
Output the complete star-bordered text box without a line count; each line has exactly width+2 characters, all spaces are kept, and the last line is followed by a newline.
样例 1
输入:
16 3
LEFT 2
hello
world
RIGHT 3
How
areYou
doing
RIGHT 3
Please look
and align
to right
输出:
******************
*hello world *
*How areYou doing*
* Please look*
* and align*
* to right*
******************
样例 2
输入:
5 1
LEFT 3
a
b
c
输出:
*******
*a b c*
*******
样例 3
输入:
5 1
RIGHT 2
a b
cc
输出:
*******
* a b*
* cc*
*******
样例说明
Example 1: the output has 7 lines of 18 characters each; hello world is padded with 5 spaces on the right, How areYou doing fills exactly 16 columns, and the last three entries each take one line, padded on the left with 5, 7, and 8 spaces respectively. Example 2: a b c exactly fills the 5 content columns, so no padding is needed. Example 3: putting a b and cc together would need 6 columns, so they must go on two lines, padded on the left with 2 and 3 spaces respectively.