| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
哪位大牛能帮我看看这个程序有什么错?我实在想不出什么数据了可以wa了……program p1659;
var s:array[0..20,0..20]of byte;
c,p:array[1..20]of longint;
n,t,i:longint;
procedure sort(l,r:longint);
var i,j,x,y:longint;
begin
i:=l;j:=r;x:=c[(l+r) DIV 2];
repeat
while c[i]<x do i:=i+1;
while x<c[j] do j:=j-1;
if i<=j then begin
y:=c[i];c[i]:=c[j];c[j]:=y;
y:=p[i];p[i]:=p[j];p[j]:=y;
i:=i+1;j:=j-1;
end;
until i>j;
if l<j then sort(l,j);
if i<r then sort(i,r);
end;
procedure init;
var i:longint;
begin
readln(n);
for i:=1 to n do begin
read(c[i]);
p[i]:=i;
end;
sort(1,n);
fillchar(s,sizeof(s),0);
end;
procedure print;
var i,j:longint;
begin
for i:=1 to n do begin
for j:=1 to n do
write(s[i,j],' ');
writeln;
end;
end;
procedure work;
var i,j:longint;
bool:boolean;
begin
i:=n;bool:=true;
while (bool)and(i>0) do begin
j:=i-1;
while (bool)and(c[i]>0) do begin
while (j>0)and(c[j]<=0) do dec(j);
if j<=0 then bool:=false
else begin
dec(c[i]);dec(c[j]);
s[p[i],p[j]]:=1;s[p[j],p[i]]:=1;
dec(j);
end;
end;
dec(i);
end;
if bool then begin
writeln('YES');
print;
end
else writeln('NO');
end;
begin
// assign(input,'input.txt');reset(input);
// assign(output,'output.txt');rewrite(output);
readln(t);
for i:=1 to t do begin
init;
work;
if i<>t then writeln;
end;
// close(input);close(output);
end.
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator