Page 1 of 2
723 - Comment Removal
Posted: Sat Aug 20, 2005 2:17 pm
by little joey
I noticed that all accepted submissions but one got Presentation Error, including mine. Two things:
- why is it permitted to have P.E. in a problem where it's all about removing spaces and empty lines?
- I'm almost certain my program outputs the correct format, so why do I get P.E.?
I'll temporarily attach my code to this posting, maybe someone can find my mistake. Please don't leach it!
Does judge output can compiled by Pascal compiler?
Posted: Sat Aug 20, 2005 10:13 pm
by avm
I also don't know how receive AC for this problem.
Please clarify this Input:
Code: Select all
var i:integer{};
begin
for i:=1 to 10 do{}writeln('''''',i);
writeln (0, {LightGreen,} 0);
end.
My P.E. Output and syntactically invalid Pascal program:
Code: Select all
var i:integer;
begin
for i:=1 to 10 dowriteln('''''',i);
writeln (0, 0);
end.
My W.A Output and syntactically valid Pascal program:
Code: Select all
var i:integer
;
begin
for i:=1 to 10 do
writeln('''''',i);
writeln (0,
0);
end.
Posted: Mon Aug 22, 2005 9:27 pm
by Dominik Michniewski
I just start to write a solution, but I think, that lines like
Code: Select all
for i:=1 to 10 do{}writeln('''''',i);
should be outputed as
Code: Select all
for i:=1 to 10 do writeln('''''',i);
Why?
Because any comment is a blank for compiler. So if we remove comment we can put a blank instead of it.
BTW. Very nice input
Best regards
DM
PS. [2 hours later] Why I am not surprised, that I am not get Acc , but WA?

Posted: Tue Aug 23, 2005 8:17 am
by Dominik Michniewski
I have one more question:
For inputs like:
Code: Select all
Program x(input,output);
var x {
}:integer;
begin end.
output should be:
Code: Select all
Program x(input,output);
var x
:integer;
begin end.
or
Code: Select all
Program x(input,output);
var x :integer;
begin end.
?
Could anyone who got accepted post some critical IO ? I try to find my mistake, but I don't have any idea what I can do wrong ...
Best regards
DM
Some tests
Posted: Wed Aug 24, 2005 10:57 pm
by avm
Since 21 August it is impossible receive P.E. for this problem.
http://online-judge.uva.es/board/viewtopic.php?t=8715
Input and output below doesn't contain trailing spaces.
Input:
Code: Select all
{Don't replace sequences of blanks with a single blank after removing comments
} {For more details read problem statement
}
(*
*
)
*)(* My pascal program fails on comment above *) Program p723(input,output);
{$D-,L-,I-,Q-,R-,S-,Y-}
var x {
}:integer;
procedure repeatuntilfalse;begin end;
begin
(* comments are removed and not replaced by blank!*)
(* This is an example that input and output programs can be different!!!*)
repeat{}until{}false;
end.
{My ACCEPTED Pascal programs works 0.131 seconds with 320Kb memory spent}
{Any hints how speed up Pascal I/O?}
{SetTextBuf function is restricted!}
AC output:
Code: Select all
Program p723(input,output);
var x :integer;
procedure repeatuntilfalse;begin end;
begin
repeatuntilfalse;
end.
Posted: Thu Aug 25, 2005 9:08 am
by Dominik Michniewski
Nice input. I think that I know now what I am doing wrong ...
Best regards
DM
Posted: Thu Aug 25, 2005 10:13 am
by Dominik Michniewski
I have no idea what's wrong with my code ...
I follow instructions from problem description and topic but I still got WA.
Could you help me avm ?
Best regards
DM
PS. Avm, I post you my code in C via private message. Maybe you could help me? If not - it will be good too

Posted: Thu Aug 25, 2005 1:32 pm
by avm
Input
Code: Select all
begin
writeln('(**)'{ *)}+'');
end.
Output
Posted: Thu Aug 25, 2005 3:42 pm
by Dominik Michniewski
Nice
I completly forgot about such things ...
Thanks avm

:)
Best regards
DM
Posted: Wed Dec 07, 2005 6:25 pm
by minskcity
I cannot see where in the problem statement is says that the comments inside the string constants should not be removed (it certainly says so about the multiple spaces in a row, but not comments)...

Posted: Sat Sep 02, 2006 9:17 pm
by Erik
Hi,
I tried all testcases in this topic and my program produced correct output.
After many tests I discovered that my program finds a string-constant in the input which is not terminated at the end of the line.
Could anyone verify this?
Of course it should not happen as it is invalid pascal. Hence I guess it doesn't which means I must handle comments the wrong way as my program then must miss some '-s.
I hope you can help me or provide additional testcases.
Cu, Erik

Posted: Tue Mar 20, 2007 1:57 pm
by Erik
Hello,
i finally got AC. It was a tricky but substantial error in my program.
Cu, Erik

Posted: Sun Jul 01, 2007 3:10 pm
by LithiumDex
My program passes all the test cases here (the good ones anyway)
My questions are:
- Do we remove all trailing spaces from the end of a line?
- If the last line in the file does not end with a \n, should a \n be displayed?
- In pascal, this is a valid comment: { *).. not here?
- This sounds kinda dumb, but if you read the problem state literally, it's saying that we should even remove comment blocks within strings, is this correct?
[EDIT]
- No
- ?
- Yes
- No
- Look out for multiline strings! (AC)
Thanks again,
Clarification
Posted: Fri Jun 08, 2012 2:25 pm
by Blackwizard
hi everyone...
anybody knows the output for my output?
input:
Code: Select all
begin;
myfunc { nothing } }
(* comment * ) *)
(*
*
)
*)
end;
tnx...
723 - Comment Removal_Clarification
Posted: Fri Jun 08, 2012 2:35 pm
by Blackwizard
hi everyone...
anybody knows the output for my output?
input:
Code: Select all
begin;
myfunc { nothing } }
(* comment * ) *)
(*
*
)
*)
end;
tnx...