A8039 | bHTML Tables Analisys
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
In this problem is used an extremely simplified version of HTML table markup. Please use the statement as a formal document and read it carefully.
A string is a bHTML table, if it satisfies the grammar:
As can be seen, the tables may be nested. You are given a table (which may contain other(s)). You need to write a program that analyzes all the tables and finds the number of cells in each of them. The tables are not required to be rectangular.
A string is a bHTML table, if it satisfies the grammar:
<br></br>TABLE ::= <table>ROWS</table><br></br>ROWS ::= ROW | ROW ROWS<br></br>ROW ::= <tr>CELLS</tr><br></br>CELLS ::= CELL | CELL CELLS<br></br>CELL ::= <td></td> | <td>TABLE</td><br></br>Blanks in the grammar are only for purposes of illustration, in the given data there will be no spaces. The bHTML table is very similar to a simple regular HTML table in which meet only the following tags : "table", "tr", "td", all the tags are paired and the table contains at least one row and at least one cell in each row. Have a look at the sample tests as examples of tables.As can be seen, the tables may be nested. You are given a table (which may contain other(s)). You need to write a program that analyzes all the tables and finds the number of cells in each of them. The tables are not required to be rectangular.
输入格式
For convenience, input data can be separated into non-empty lines in an arbitrary manner. The input data consist of no more than 10 lines. Combine (concatenate) all the input lines into one, to get a text representation $s$ of the specified table. String $s$ corresponds to the given grammar (the root element of grammar is TABLE), its length does not exceed 5000. Only lower case letters are used to write tags. There are no spaces in the given string $s$ .
输出格式
Print the sizes of all the tables in the non-decreasing order.
输入输出样例
输入 #1
<table><tr><td></td></tr></table>
输出 #1
1
输入 #2
<table> <tr> <td> <table><tr><td></td></tr><tr><td></ td ></tr><tr ><td></td></tr><tr><td></td></tr></table> </td> </tr> </table>
输出 #2
1 4
输入 #3
<table><tr><td> <table><tr><td> <table><tr><td> <table><tr><td></td><td></td> </tr><tr><td></td></tr></table> </td></tr></table> </td></tr></table> </td></tr></table>
输出 #3
1 1 1 3
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted