Logo
(追記) (追記ここまで)

5076번 - Web Pages 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 128 MB124054441943.600%

문제

You probably know about HTML, the mark up language used to create Web pages. HTML code contains a number of tags which are expected to follow certain rules.

In this problem we will be concerned with two of these rules:

  1. Every opening tag has to have a corresponding closing tag
  2. All tags must be properly nested.

Tags are marked by angled brackets which contain a keyword, such as <body> or <strong>. These are opening tags, the corresponding closing tags having / before the keyword, ie </body> and </strong>. It is possible for a tag to be both opening and closing, such as <br />, which complies with rule 1.

To be properly nested, if a tag is opened inside another tag, it must be closed before the other tag closes. For example

  • <body> <strong> </strong> </body> is properly nested
  • <body> <strong> </body> </strong> is not, and breaks rule 2.

If there are no tags present, the text complies with both rules.

Attributes may be present within an opening tag, such as

<a href="http://www.nzprogcontest.org.nz">This is a link</a>

The closing tag has only to match the keyword, not the attributes.

입력

Input will consist of a number of lines of HTML code, each line containing from 0 to 255 characters. The last line will contain a single # character – do not process this line. Within the text of each line will be zero or more tags. No angle bracket will be present unless it is part of a properly formed tag.

Determine whether or not the HTML meets the rules specified above.

출력

Output will consist of a single line for each line of input. The line will contain either the word legal, or the word illegal.

제한

예제 입력 1

<body> <strong>Oops, this is</body> naughty </strong>
<body> <strong>Hello</strong> <br /> </body>
Just text, no tags.
<p> Oh dear, we are missing something.
<a href="http://www.nzprogcontest.org.nz">This is a link</a>
#

예제 출력 1

illegal
legal
legal
illegal
legal

힌트

출처

ICPC > Regionals > South Pacific > South Pacific Region > New Zealand Programming Contest > NZPC 2012 E번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /