cswork / OA打开练习工作台

Capital OneOA #1

Newspaper Page Layout — Multi-paragraph Justification

估计中等评测数据准备中,可先阅读题面

考点(AI 标注)字符串模拟/实现

You are moderating a newspaper page, and you have to align the text on the page properly. The text is provided to you in the following format:

  • paragraphs is an array of paragraphs, where each paragraph is represented as an array of words.
  • aligns is an array representing the alignment of each paragraph from paragraphs — each element is either "LEFT" or "RIGHT".
  • width represents the maximum number of characters each line of the output can include.

For each paragraph, include all the words paragraphs[i][j], in order, separated by spaces:

  • Include as many words as possible per page line (the length of the line must be less than or equal to width), and put the next word on a new line if it would exceed this limit.
  • In the case of excess whitespace, words from paragraphs[i] should be aligned according to aligns[i]. If aligns[i] = "LEFT", the line should have no leading spaces.
  • Include a border of '*' characters around all the edges of the result.