from TLE in Pascal to 0.000 secs in C

Write here if you have problems with your Pascal source code

Moderator: Board moderators

Post Reply
WR
Experienced poster
Posts: 145
Joined: Thu Nov 27, 2003 9:46 am

from TLE in Pascal to 0.000 secs in C

Post by WR » Fri Mar 26, 2004 9:03 am

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

CDiMa
Experienced poster
Posts: 214
Joined: Fri Oct 17, 2003 5:49 pm
Location: Genova

Re: from TLE in Pascal to 0.000 secs in C

Post by CDiMa » Fri Mar 26, 2004 9:46 am

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
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.

Ciao!!!

Claudio

WR
Experienced poster
Posts: 145
Joined: Thu Nov 27, 2003 9:46 am

Post by WR » Fri Mar 26, 2004 9:52 am

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?

CDiMa
Experienced poster
Posts: 214
Joined: Fri Oct 17, 2003 5:49 pm
Location: Genova

Post by CDiMa » Fri Mar 26, 2004 10:31 am

WR 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?
You check for CR while you should check for LF ;)

Ciao!!!

Claudio

WR
Experienced poster
Posts: 145
Joined: Thu Nov 27, 2003 9:46 am

Post by WR » Fri Mar 26, 2004 11:45 am

Well of course. :oops:

Time for the weekend!

Have a nice day!

Post Reply

Return to “Pascal”