Submit | All submissions | Best solutions | Back to list |
XMLCHECK - XML Checker |
XML is an extension of HTML. In XML, the user can introduce a tag set that describes the data that he is working with. There are various rules that determine a valid XML document. The program that you will write will check two of those rules.
Rule I: A beginning tag must have an ending tag. A beginning tag is represented by <tag_name> and the corresponding ending tag is represented by </tag_name>.
Rule II: An element defined by one pair of beginning and ending tags may nest completely inside another pair of beginning and ending tags but they may not overlap.
Valid XML:
<address> <street> 123 Any Street </street> <city> Any City </city> </address>
Invalid XML:
<address> <street> 123 Any Street </street> <city> Any City </address> </city>
Your program will determine if a snippet of XML code conforms to these two rules or not.
Input
The first line of input will contain a single integer n that indicates the number of data sets to follow. For each data set, the first line will contain a single integer m that indicates the number of lines that follow in that snippet of XML code.
Output
For each snippet of XML code you will write valid or invalid on a line by itself.
Example
Input: 2
4
<student>
<name>
John Doe
</student>
2
<gpa>
</gpa>Output:
invalid valid
Added by: | BYU Admin |
Date: | 2015-12-15 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ASM64 MAWK BC NCSHARP COFFEE DART FORTH GOSU JS-MONKEY JULIA KTLN OCT PROLOG PYPY3 R RACKET SQLITE SWIFT UNLAMBDA |
Resource: | UIL District 2 2011 #12 |