Thanks Larry and Per for your replies. I finally figured it out and got AC.
I now use my own buffered input, considering every non-numeric character as whitespace and reading integers one at the time. This is what I use:
[pascal]program test;
var
inputbuffer:string;
bufpos,buflen:integer;
procedure myread(var i:integer);
label reload;
begin
reload:
while (bufpos>buflen) do begin
readln(inputbuffer);
buflen:=length(inputbuffer);
bufpos:=1;
end;
while ((bufpos<=buflen) and not (inputbuffer[bufpos] in ['0'..'9']))
do inc (bufpos);
if (bufpos>buflen) then goto reload;
i:=0;
while ((bufpos<=buflen) and (inputbuffer[bufpos] in ['0'..'9'])) do begin
i:=10*i+ord(inputbuffer[bufpos])-ord('0');
inc (bufpos);
end;
end;
var
mink,roads,cities:integer;
c1,c2,r:integer;
begin
buflen:=0;
bufpos:=1;
repeat
myread(cities);
myread(roads);
myread(mink);
if ((cities=0) and (roads=0) and (mink=0)) then break;
for r:=1 to roads do begin
myread(c1);
myread(c2);
end;
until false;
end.[/pascal]
Some processing logic should be added to get accepted though...
I truely believe the problemsetters didn't add the rubbish in the input on purpose, and I'm sure they didn't notice it because their C/C++ programs handled it correctly, but it realy spoiled the contest for this old Pascal programmer. I wonder how many Pascal programs got AC during the contest. I bet it's zero...