Hi,
for a Pascal program solving problem 337 the Online Judge returned Time Length Exceeded. After transcribing the program to C the program was accepted in 0.000 seconds. The only difference between the programs
is the End of Line handling.
[pascal]if (ch <> #13) then
PutChar(ch,ins,curx,cury) (* update matrix *)
else begin
read(input,ch); (* read character #10 *)
end;
[/pascal]
[c]if (ch != '\n')
pchar(ch,ins,&curx,&cury);
/* else nothing */[/c]
Needless to say that both versions work on my Windows PC.
Could somebody please explain why the Pascal version has a problem with the Online Judge?!
Thanks
from TLE in Pascal to 0.000 secs in C
Moderator: Board moderators
Re: from TLE in Pascal to 0.000 secs in C
The online judge doesn't run on a Windows PC. Text files on a Unix machine don't use CR/LF as a line terminator but only the LF character.WR wrote:[pascal]if (ch <> #13) then
PutChar(ch,ins,curx,cury) (* update matrix *)
else begin
read(input,ch); (* read character #10 *)
end;
[/pascal]
[c]if (ch != '\n')
pchar(ch,ins,&curx,&cury);
/* else nothing */[/c]
Needless to say that both versions work on my Windows PC.
Could somebody please explain why the Pascal version has a problem with the Online Judge?!
Thanks
Ciao!!!
Claudio
You check for CR while you should check for LFWR wrote:Thank you Claudio,
I'll delete the second read in my Pascal program and submit it again.
We'll see.
1 minute later:
OK, TLE again of course, checking for character #13 obviously doesn't make sense. But checking for Eoln doesn't work on my PC. Any solution?
![;)](./images/smilies/icon_wink.gif)
Ciao!!!
Claudio