I coded it in Pascal and have no problem with reading the input. Here is reading part from my Pascal program:dreadlord wrote:WARNING:
Don't try to solve this problem with a Pascal program. I believe there is some problem with the I/O in Pascal with the input file. I tried the following extremely simple program:
, which of course may not expect to get AC, but definitely shouldn't ever get Time Limit Exceeded, as it does. I get no problems when using this loops structure in my computer.Code: Select all
program hang932; var TC, i, j : Integer; car : Char; begin while eoln and not eof do readln; (* skip leading newlines *) readln (TC); i := 1; repeat j := 1; repeat car := '.'; repeat if eoln then readln else read (car) until (car = '0') or (car = 'X'); if j = TC then break; inc (j); until False; if i = TC then break; inc (i); until False; writeln ('NO'); writeln ('NO') end.
I believe this' something to do with the first readln(TC), as I get WA (as expected) when replacing the two outermost repeat-until loops by "for [ i | j ] := 1 to TC do". Maybe it gets zero for TC for some reason? Might this happen because the input text file contains some stranger line terminators, kind of DOS or so?
Code: Select all
program pr932;
var tab:array[0..31,0..31]of char;
n,i,j:longint;
begin
while not eof(input) do
begin
readln(n);
for i:=1 to n do
begin
for j:=1 to n do read(tab[i,j]);
readln;
end;
{ ... }
end;
end.