比赛 |
20100914 |
评测结果 |
WWAWWAWWWW |
题目名称 |
关键子工程 |
最终得分 |
20 |
用户昵称 |
donny |
运行时间 |
0.000 s |
代码语言 |
Pascal |
内存使用 |
0.00 MiB |
提交时间 |
2010-09-14 21:45:53 |
显示代码纯文本
program project(input,output);
var
i,j,k,l,n,m:integer;
a:array[1..200,1..200]of integer;
early,late,time,rudu,chudu,jilu:array[1..200]of integer;
b:array[1..200]of boolean;
guan:array[0..200]of integer;
begin
assign(input,'project.in');
reset(input);
assign(output,'project.out');
rewrite(output);
readln(n);
for i:=1 to n do
read(time[i]);
readln;
for i:=1 to n do
a[i,i]:=0;
for i:=1 to n do
rudu[i]:=0;
for i:=1 to n do
chudu[i]:=0;
for i:=1 to n do
begin
for j:=1 to n-1 do
if j>=i then
begin
read(a[i,j+1]);
if a[i,j+1]=1 then begin inc(rudu[i]); inc(chudu[j+1]); end;
end
else
begin
read(a[i,j]);
if a[i,j]=1 then begin inc(rudu[i]); inc(chudu[j]); end;
end;
readln;
end;
for i:=1 to n do
late[i]:=time[i];
for i:=1 to n do
if rudu[i]>0 then
early[i]:=0
else early[i]:=time[i];
for i:=1 to n do
jilu[i]:=0;
for i:=1 to n do
b[i]:=true;
m:=0;
while m<n do
begin
k:=m;
for i:=1 to n do
if (rudu[i]=0)and(b[i]) then
begin
b[i]:=false;
inc(m);
if m=n then
begin
writeln(early[i]);
guan[0]:=0;
m:=0;
for j:=1 to n do
b[j]:=true;
for j:=1 to n do
jilu[j]:=maxint;
for j:=1 to n do
if chudu[j]=0 then late[j]:=early[j];
while m<>n do
begin
for j:=1 to n do
if (chudu[j]=0)and(b[j]) then
begin
b[j]:=false;
inc(m);
for k:=1 to n do
begin
if j<>k then
begin
if a[j,k]=1 then
begin
dec(chudu[k]);
if early[j]-time[j]<jilu[k] then jilu[k]:=early[j]-time[j];
if chudu[k]=0 then
late[k]:=jilu[k];
end;
end;
end;
end;
end;
for j:=1 to n do
if early[j]=late[j] then
begin
inc(guan[0]);
guan[guan[0]]:=j;
end;
for l:=1 to guan[0] do
for j:=1 to guan[0]-1 do
if guan[j]>guan[j+1] then
begin
k:=guan[j];
guan[j]:=guan[j+1];
guan[j+1]:=k;
end;
for j:=1 to guan[0]-1 do
write(guan[j],' ');
writeln(guan[guan[0]]);
close(input);
close(output);
halt;
end;
for j:=1 to n do
begin
if i<>j then
begin
if a[j,i]=1 then
begin
dec(rudu[j]);
if early[i]>jilu[j] then jilu[j]:=early[i];
if rudu[j]=0 then
early[j]:=jilu[j]+time[j];
end;
end;
end;
end;
if k=m then
begin
writeln('-1');
close(input);
close(output);
halt;
end;
end;
close(input);
close(output);
end.