342 - HTML Syntax Checking

All about problems in Volume 3. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

Dominik Michniewski
Guru
Posts: 834
Joined: Wed May 29, 2002 4:11 pm
Location: Wroclaw, Poland
Contact:

342 - HTML Syntax Checking

Post by Dominik Michniewski » Mon Oct 31, 2005 12:01 pm

I have a few questions to this problem:

1. Sample imput isn't correct. Test case 5 tells that 2 lines of text follow, but is only one line of text.
2. Can we handle < and > as start and end of the tag (as in first case in the sample)? Such situations are incorrect in HTML as far as I remember.
3. Can we handle tags without body (something like <TAG />? Specification don't say any word about that.

I use stack to check nested tags and I hope that my program is correct, but I got WA only. Could anyone help me ?

Bets regards
DM
If you really want to get Accepted, try to think about possible, and after that - about impossible ... and you'll get, what you want ....
Born from ashes - restarting counter of problems (800+ solved problems)

User avatar
little joey
Guru
Posts: 1080
Joined: Thu Dec 19, 2002 7:37 pm

Post by little joey » Mon Oct 31, 2005 1:31 pm

The sample I/O was not correct, so I made a description one called p342.html. In updating the new page, the judges must have forgotten to overwrite the old description (342.html) with the new one, but instead copied it. So the correct description can be found at http://acm.uva.es/p/v3/p342.html.
Sorry for the inconvenience; I'll notify the judges immediately.

As for your questions 1&2: see new description.

What do you mean by "tags without body"? The only valid tags are opening tags (without the slash) and closing tags (with a slash immediatly following the '<'), and they should always appear in pairs, as given in the description.

Dominik Michniewski
Guru
Posts: 834
Joined: Wed May 29, 2002 4:11 pm
Location: Wroclaw, Poland
Contact:

Post by Dominik Michniewski » Mon Oct 31, 2005 1:59 pm

Unfortunatly link which you post doesn;t work :( (I got HTTP error 404).

So, could you send me this new HTML page ??

Tag without body is something like <br /> , which is shorthand from <br></br>.

Best regards
DM
If you really want to get Accepted, try to think about possible, and after that - about impossible ... and you'll get, what you want ....
Born from ashes - restarting counter of problems (800+ solved problems)

User avatar
little joey
Guru
Posts: 1080
Joined: Thu Dec 19, 2002 7:37 pm

Post by little joey » Mon Oct 31, 2005 2:20 pm

In the meantime Carlos fixed the problem, so the new desciption can be found at the normal adress (http://acm.uva.es/p/v3/342.html). You might need to reload the page in your browser to refresh your cache.

No, all tags should be matched.

Dominik Michniewski
Guru
Posts: 834
Joined: Wed May 29, 2002 4:11 pm
Location: Wroclaw, Poland
Contact:

Post by Dominik Michniewski » Mon Oct 31, 2005 2:34 pm

Thanks, I see new description :)

Best regards
DM
If you really want to get Accepted, try to think about possible, and after that - about impossible ... and you'll get, what you want ....
Born from ashes - restarting counter of problems (800+ solved problems)

Dominik Michniewski
Guru
Posts: 834
Joined: Wed May 29, 2002 4:11 pm
Location: Wroclaw, Poland
Contact:

Post by Dominik Michniewski » Mon Oct 31, 2005 3:28 pm

I have one question:

Why, in case 9, output is

Code: Select all

bad character in tag name.
?
Tag has 11 characters, so I think, that output should be

Code: Select all

too many/few characters in tag name.
This situation violates two rules. Which one should be used?

Best regards
DM
If you really want to get Accepted, try to think about possible, and after that - about impossible ... and you'll get, what you want ....
Born from ashes - restarting counter of problems (800+ solved problems)

User avatar
little joey
Guru
Posts: 1080
Joined: Thu Dec 19, 2002 7:37 pm

Post by little joey » Mon Oct 31, 2005 4:06 pm

The problem description doesn't specify what to do if both errors occur simultaniously. In case 9 the eleventh character is illegal, but also makes the tag too long, so both errors would apply for that tag. I had to make a choice, so I chose to issue the errors in the same order as they were given in the text, which means in case 9 the output is "bad character in tag name".

I added three cases to the sample input to (implicitly) illustrate which choice I made.
In case 8 the bad character appears before the character that makes the tag too long;
In case 10 the bad character appears after the character that makes the tag too long.

Dominik Michniewski
Guru
Posts: 834
Joined: Wed May 29, 2002 4:11 pm
Location: Wroclaw, Poland
Contact:

Post by Dominik Michniewski » Mon Oct 31, 2005 4:19 pm

Thanks little joey for explanation.
Now my output is exactly the same as in samples, but I got WA again.

I don't think, that my stack algorihtm fails, but I must miss some critical cases. But I don't know which one I missed ! I think, that must be something more with output - maybe any other message should appear?
Could you take a look at outputs from my code ? Can I send you my code ?

Best regards
DM
If you really want to get Accepted, try to think about possible, and after that - about impossible ... and you'll get, what you want ....
Born from ashes - restarting counter of problems (800+ solved problems)

User avatar
little joey
Guru
Posts: 1080
Joined: Thu Dec 19, 2002 7:37 pm

Post by little joey » Mon Oct 31, 2005 4:29 pm

Sure you can send me your code.

Emilio
Experienced poster
Posts: 163
Joined: Sun Oct 17, 2004 8:31 pm
Location: Murcia, Spain

Post by Emilio » Sat Nov 05, 2005 6:20 pm

Hi all!

I'm getting WAs.
Could you say me what is the output for this?

[EDIT] Now cases 3 and 4 are correct as regards problem's specification [/EDIT]

Code: Select all

2

<EMILIOJOSE> </EMILIOJOSE>
2

<EMILIOJOSe> </EMILIOJOSe>
2

<EMILIOJOSE> </EMILIOJOSe>
2

<EMILIOJOSEe> </EMILIOJOSEe>
2
<EMILIOJOSEE> </EMILIOJOSEE>

2
    >   

2

    />
2

   </>
2

  </ >
2

< >
3

<ASDFG>

4

<ASDF>

</>
4

<ASDF>

</ >
4

<ASDF>

</ASD>
0
my output:

Code: Select all

Test Case 1
OK
Test Case 2
line 2: bad character in tag name.
Test Case 3
line 2: bad character in tag name.
Test Case 4
line 2: bad character in tag name.
Test Case 5
line 1: too many/few characters in tag name.
Test Case 6
line 1: bad character in tag name.
Test Case 7
line 2: bad character in tag name.
Test Case 8
line 2: too many/few characters in tag name.
Test Case 9
line 2: bad character in tag name.
Test Case 10
line 2: bad character in tag name.
Test Case 11
line 3: no matching begin tag.
Test Case 12
line 4: too many/few characters in tag name.
Test Case 13
line 4: bad character in tag name.
Test Case 14
line 4: expected </ASDF>
And a small commentary, in the problem's specification there are this:
line #: bad character in tag name
line #: too many/few characters in tag name
line #: expected </xxxxxxxxxx>
line #: no matching begin tag.
In the sample output:
line #: bad character in tag name.
line #: too many/few characters in tag name.
line #: expected </xxxxxxxxxx>
line #: no matching begin tag.
I think that clearly the correct for output are the second ones (if you notice the first and second statement haven't the spot at line's finish).

Thanks in advance!
Last edited by Emilio on Sun Nov 06, 2005 9:17 pm, edited 3 times in total.

User avatar
little joey
Guru
Posts: 1080
Joined: Thu Dec 19, 2002 7:37 pm

Post by little joey » Sun Nov 06, 2005 10:21 am

My output is:

Code: Select all

Test Case 1
OK
Test Case 2
line 2: bad character in tag name.
Test Case 3
line 2: bad character in tag name.
Test Case 4
line 2: bad character in tag name.
Test Case 5
line 1: too many/few characters in tag name.
Test Case 6
OK
Test Case 7
OK
Test Case 8
line 2: too many/few characters in tag name.
Test Case 9
line 2: bad character in tag name.
Test Case 10
line 2: bad character in tag name.
Test Case 11
line 3: expected </ASDFG>
Test Case 12
line 4: too many/few characters in tag name.
Test Case 13
line 4: bad character in tag name.
Test Case 14
line 4: expected </ASDF>
Your cases 3 and 4 are invalid (three lines, while n=2). Cases 5 and 6 contain no tags (a tag should have both '<' and '>'), just text and therefor are 'OK'.

Thanks for noticing the difference between the description and the sample output. I corrected some other errors in the problem, but never noticed this one... There should be a dot after the first, second anf fourth error message, as in the sample output.

Emilio
Experienced poster
Posts: 163
Joined: Sun Oct 17, 2004 8:31 pm
Location: Murcia, Spain

Post by Emilio » Sun Nov 06, 2005 9:13 pm

Thanks for the reply!

I got AC.
With your output I have seen that I considered of another way some cases.

edumneves
New poster
Posts: 3
Joined: Tue Apr 18, 2006 4:05 am

Post by edumneves » Tue Apr 18, 2006 4:09 am

Hi,
My program is with wrong answer and all this tests here gave me the same output.

What is the correct solution for this test?

Sample input

Code: Select all

2
<TESTE>
</TTESTE>
2
<TESTEA><TESTEB>
</TESTEA></TESTEB>
0 
Mine output :

Code: Select all

Test Case 1
line 2: expected </TESTE>
Test Case 2
line 2: expected </TESTEB>

edumneves
New poster
Posts: 3
Joined: Tue Apr 18, 2006 4:05 am

More cases

Post by edumneves » Tue Apr 18, 2006 4:31 am

In this case:

Code: Select all

4
<A> </A>
<AB><ABC>
</ABC>

1
blabla<BLA>blabla</Blalalalla>
1
blabla<BLA>blabla</BLALALALALLALALA>
2
blabla<BLA>blabla<BLALALALAL>
</BLALALALAL>
0 
My W.A. solution is giving:

Code: Select all

Test Case 1
line 4: expected </AB>
Test Case 2
line 1: bad character in tag name.
Test Case 3
line 1: too many/few characters in tag name.
Test Case 4
line 2: expected </BLA>
What is the correct solution for this test case?

thanks for the help

edumneves
New poster
Posts: 3
Joined: Tue Apr 18, 2006 4:05 am

Post by edumneves » Wed Apr 19, 2006 2:49 pm

Got accepted finnally ...

Those test cases that I posted have the right solution, the problem was that the number of tags in this problem is really big and the size of the line too.

Post Reply

Return to “Volume 3 (300-399)”