Page 1 of 3
342 - HTML Syntax Checking
Posted: Mon Oct 31, 2005 12:01 pm
by Dominik Michniewski
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
Posted: Mon Oct 31, 2005 1:31 pm
by little joey
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.
Posted: Mon Oct 31, 2005 1:59 pm
by Dominik Michniewski
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
Posted: Mon Oct 31, 2005 2:20 pm
by little joey
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.
Posted: Mon Oct 31, 2005 2:34 pm
by Dominik Michniewski
Thanks, I see new description
Best regards
DM
Posted: Mon Oct 31, 2005 3:28 pm
by Dominik Michniewski
I have one question:
Why, in case 9, output is
?
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
Posted: Mon Oct 31, 2005 4:06 pm
by little joey
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.
Posted: Mon Oct 31, 2005 4:19 pm
by Dominik Michniewski
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
Posted: Mon Oct 31, 2005 4:29 pm
by little joey
Sure you can send me your code.
Posted: Sat Nov 05, 2005 6:20 pm
by Emilio
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!
Posted: Sun Nov 06, 2005 10:21 am
by little joey
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.
Posted: Sun Nov 06, 2005 9:13 pm
by Emilio
Thanks for the reply!
I got AC.
With your output I have seen that I considered of another way some cases.
Posted: Tue Apr 18, 2006 4:09 am
by edumneves
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>
More cases
Posted: Tue Apr 18, 2006 4:31 am
by edumneves
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
Posted: Wed Apr 19, 2006 2:49 pm
by edumneves
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.