F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

XML

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 308    Accepted Submission(s): 80


Problem 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:

1. Plain text---ASCII codes between 32 and 127 (inclusive), with none of the following symbols: <, >, &
2. The sequences:
* &lt;
* &gt;
* &amp;
These encode a <, >, or & respectively.
3. &xHEX; HEX must be any even (positive) number of upper or lower case hexadecimal digits, and this represents the bytes given.
4. <tag> Tag can be any lowercase alphanumeric string. This tag is pushed onto the context stack.
5. <tag/> This tag is not pushed onto the context stack (there is no closing context).
6. </tag> This tag removes the <tag> context from the stack, which must be topmost on the stack.

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 oftext 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 &amp; socks.</doc> 3x+5&gt;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
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-11-22 20:30:06, Gzip enabled