当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

1441:Table

题目描述
A lot of text editors allows us to make tables with the help of pseudographical characters but do not let edit them, i.e. after alternation of the text in cells, to restore the marking of lines and columns you have to align the whole table manually. You are offered to implement an editor fragment carrying out an automatic table alignment.

The table represents a rectangle divided into cells with vertical and horizontal lines, linking its borders. Vertical and horizontal markers as well as the rectangle itself are formed by pseudographical characters from figure 1.

The text in table cells can be located in several lines. Text does not contain control and pseudographical characters.

While editing a table the text of cells is being changed and as a result symbols 'i' can be shifted to the left or to the right. The number of lines and columns of the table as well as the number of lines in each cell is not being changed.

The text in each line of each cell should be separated from vertical markers exactly with one space on the left and no less than with one space on the right in the aligned table. All spaces between words are significant. It is allowed only:

to alter the number of leading and trailing spaces in cell lines;
to add and delete characters "--" (ASCII 196) in horizontal table markers.
The table does not contain empty columns, i.e. each column contains at least one cell with non-empty text.

It is required to format a given table making its width (the length of table line) minimal.
输入解释
Input contains an edited table. It consists of no more than 100 lines and line length is no more then 255 characters. Lines themselves do not contain leading and trailing spaces. The input does not contain empty lines.
输出解释
Write to the output the aligned table. Output lines should not contain leading and trailing spaces. The output should not contain empty lines. The input provides that the width of the formatted table does not exceed 255 characters.
输入样例
┌───────┬───────────────────────┬──────────────────────────────────────┐
│ Name         │ Organization     │ JOB      │
├───────┼───────────────────────┼──────────────────────────────────────┤
│Bill Clinton│  USA      │ The President of the United States │
├───────┼───────────────────────┼──────────────────────────────────────┤
│Bill Gates│Microsoft Corporation     │ President                         │
├───────┼───────────────────────┼──────────────────────────────────────┤
│ Bill Poucher  │     A  C  M    │           International Collegiate Programming │
│                │               │      Contest Director                     │
└───────┴───────────────────────┴──────────────────────────────────────┘
输出样例
┌──────────────┬───────────────────────┬──────────────────────────────────────┐
│ Name         │ Organization          │ JOB                                  │
├──────────────┼───────────────────────┼──────────────────────────────────────┤
│ Bill Clinton │ USA                   │ The President of the United States   │
├──────────────┼───────────────────────┼──────────────────────────────────────┤
│ Bill Gates   │ Microsoft Corporation │ President                            │
├──────────────┼───────────────────────┼──────────────────────────────────────┤
│ Bill Poucher │ A  C  M               │ International Collegiate Programming │
│              │                       │ Contest Director                     │
└──────────────┴───────────────────────┴──────────────────────────────────────┘

该题目是Virtual Judge题目,来自 北京大学POJ

源链接: POJ-1441

最后修改于 2020-10-29T06:04:14+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
1000 10000