CF51B.bHTML Tables Analisys
普及+/提高
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
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:
TABLE ::=
ROWS ::= ROW | ROW ROWS
ROW ::=
CELLS ::= CELL | CELL CELLS
CELL ::=
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.
本题使用一种极度简化的 HTML 表格标记语法。请将本题陈述视为正式文档,并仔细阅读。
一个字符串是 bHTML 表格,当且仅当它满足如下文法:
TABLE ::= <table>ROWS</table>
ROWS ::= ROW | ROW ROWS
ROW ::= <tr>CELLS</tr>
CELLS ::= CELL | CELL CELLS
CELL ::= <td></td> | <td>TABLE</td>
文法中的空白仅用于示意,在实际输入数据中不存在任何空格。该 bHTML 表格与一种简单的标准 HTML 表格非常相似,其中仅出现以下标签:"table"、"tr"、"td";所有标签均成对出现,且表格至少包含一行,每行至少包含一个单元格。请参考样例测试以了解表格的具体形式。
如上所示,表格可以嵌套。你将获得一个(可能包含其他表格的)表格。你需要编写一个程序,分析所有表格,并求出每个表格所含的单元格数量。表格不要求是矩形的。
输入格式
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.
为方便起见,输入数据可被任意划分为若干非空行。输入数据最多包含 10 行。将所有输入行合并(拼接)为一行,从而得到所指定表格的文本表示 s。字符串 s 符合给定的文法(文法的根元素为 TABLE),其长度不超过 5000。标签仅使用小写字母书写。给定的字符串 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
输入解题思路,AI测评打分。不知道怎么写?