시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
1 초 | 128 MB | 38 | 16 | 10 | 33.333% |
XML, eXtensible Markup Language, is poised to become the lingua franca of structured data communication for the foreseeable future, due in part to its strict formatting requirements. XML parsers must report anything that violates the rules of a well-formed XML document. An XML document is said to be well-formed if it meets all of the well-formedness constraints as defined by the World Wide Web Consortium (W3C) XML specification.
XML documents are composed of units called elements, that contain either character data and/or other elements. Elements may also contain within their declaration values called attributes. Consider the following XML document:
<?xml version="1.0"?> <customer> <name> <first>John</first> <last>Doe</last> </name> <address> <street> <number>15</number> <direction>West</direction> <name>34th</name> </street> <city>New York</city> <state-code>NY</state-code> <zip-code format="PLUS4">10001-0001</zip-code> <country-code>USA</country-code> </address> <orders/> </customer>
The bold identifiers contained within angle brackets are the elements of the document. The italicized identifier "format" within the "zip-code" element is an attribute of that element. All elements, with the exception of "orders", have a start and an end declaration, also called a tags. The "orders" element is an empty element, as indicated by the "/>" sequence that closes the element, and does not require a separate end-tag. The first line is a processing instruction for an XML parser and is not considered an element of the document.
The rules for a well-formed document are:
The input file will contain a series of XML documents. The start of each document is identified by a line containing only the processing instruction "<?xml version="1.0"?>". The end of the input is identified by a line containing only the text "<?end?>" (this is not a true XML processing instruction, just a sentinel used to mark the end of the input for this problem). As with all XML documents, white space between elements and attributes should be ignored. You may make the following assuptions with regard to the input.
For each input XML document, output a line containing the text "well-formed" if the document is well-formed, "non well-formed" otherwise.
<?xml version="1.0"?> <acm-contest-problem> <title>A Well-Formed Problem</title> <text>XML, eXtensible Markup Language, is poised to become the lingua franca of structured data communication for the foreseeable future. [...]</text> <input>probleme.in</input> <output>probleme.out</output> </acm-contest-problem> <?xml version="1.0"?> <shopping-list> <items> <item quantity="1" quantity="1">Gallon of milk</item> <item>Frozen pizza </items> </Shopping-list> <errand-list> <errand>Get some cash at the ATM <errand>Pick up dry cleaning</errand> </errand> </errand-list> <?end?>
well-formed non well-formed
ICPC > Regionals > North America > Greater New York Region > 2000 Greater New York Programming Contest E번