Re: WA8. Give me tests plz
Posted by
Oracle 19 Oct 2007 16:13
Here is testgen, I used to accept this problem, maybe it will help you:
program gen;
{$APPTYPE CONSOLE}
const n=1000;
const m=100000;
var a:array [1..n] of Integer;
was:array [1..n,1..n] of Boolean;
i,buf,buf1:Integer;
begin
randomize;
assignfile(output,'in.txt');rewrite(output);
fillchar(was,sizeof(was),0);
for i:=1 to n do
was[i,i]:=true;
for i:=1 to n do
a[i]:=random(10000)-random(10000);
writeln(n,' ',m);
for i:=1 to m do
begin
repeat
buf:=random(n)+1;
buf1:=random(n)+1;
until was[buf,buf1]=false;
was[buf,buf1]:=true;
was[buf1,buf]:=true;
{ if i=60000 then
writeln(buf,' ',buf1,' ',a[buf]+a[buf1]+1) else}
writeln(buf,' ',buf1,' ',a[buf]+a[buf1]);
end;
writeln;
for i:=1 to n do
writeln(a[i]);
closefile(output);
end.