Pro.ID21288 TitleXML Title链接http://10.20.2.8/oj/exercise/problem?problem_id=21288 AC0 Submit0 Ratio- 时间&空间限制描述In this problem, you are asked to determine if a given document satisfies the syntax of an XML-like language. A simple XML-like document can be parsed as a sequence of the following:
By the time the entire document is parsed, the context stack is empty for a valid document. We should also note that the empty string is considered valid. 输入You will be given a number of documents to process. Each document is given as one line of text which may be empty. The input is terminated by the end of file. 输出Description In this problem, you are asked to determine if a given document satisfies the syntax of an XML-like language. A simple XML-like document can be parsed as a sequence of the following:
By the time the entire document is parsed, the context stack is empty for a valid document. We should also note that the empty string is considered valid. Input You will be given a number of documents to process. Each document is given as one line of text which may be empty. The input is terminated by the end of file. Output For each document given, print valid on a single line if it is a valid XML-like document, or invalid otherwise. Sample Input the quick brown fox.
the <i><b>quick</b> brown</i> fox.
<doc>fox & socks.</doc>
3x+5>7
Null: &x00;
<doc>the quick brown fox.
the <i>quick <b>brown</i></b> fox
fox & socks.
3x+5>7
Null: &x0; Sample Output valid
valid
valid
valid
valid
invalid
invalid
invalid
invalid
invalid Source 样例输入the quick brown fox.
the <i><b>quick</b> brown</i> fox.
<doc>fox & socks.</doc>
3x+5>7
Null: &x00;
<doc>the quick brown fox.
the <i>quick <b>brown</i></b> fox
fox & socks.
3x+5>7
Null: &x0; 样例输出valid
valid
valid
valid
valid
invalid
invalid
invalid
invalid
invalid 作者 |