比赛 |
HAOI2009 模拟试题4 |
评测结果 |
AAAAAAAAAA |
题目名称 |
K- 联赛 |
最终得分 |
100 |
用户昵称 |
苏轼 |
运行时间 |
0.000 s |
代码语言 |
Pascal |
内存使用 |
0.00 MiB |
提交时间 |
2009-04-24 10:38:39 |
显示代码纯文本
{
rp++
haoi2009 moni4 kleague
time:2009.4.24
}
program cch(input,output);
const
rand=1000;
var
w,d,ans:array[1..30] of longint;
n,tot:longint;
a:array[1..100,1..100] of longint;
procedure init;
var
i,j:integer;
begin
assign(input,'kleague.in');
assign(output,'kleague.out');
reset(input);
rewrite(output);
readln(n);
for i:=1 to n do
read(w[i],d[i]);
for i:=1 to n do
for j:=1 to n do
read(a[i,j]);
end;
function check(k:longint):boolean;
var
i,j,ch,p:longint;
s:array[1..30] of longint;
g,f:array[1..30,1..30] of longint;
begin
for i:=1 to n do s[i]:=w[i];
for i:=1 to n do
for j:=1 to n do
g[i,j]:=a[i,j];
for i:=1 to n do
for j:=1 to n do
f[i,j]:=0;
for i:=1 to n do
begin
s[k]:=s[k]+g[k,i];
g[k,i]:=0; g[i,k]:=0;
end;
ch:=0;
for i:=1 to n do
for j:=i+1 to n do
inc(ch,g[i,j]);
while ch<>0 do
for i:=1 to n do
for j:=i+1 to n do
if g[i,j]>0 then
begin
dec(g[i,j]);
dec(ch);
if s[i]<s[j] then begin
inc(s[i]); inc(f[i,j]);
end
else begin
inc(s[j]); inc(f[j,i]);
end;
end;
for i:=1 to rand do
for j:=1 to n do
for p:=1 to n do
if (f[j,p]>0)and(s[j]>s[p]) then
begin
dec(s[j]); inc(s[p]);
dec(f[j,p]);
end;
for i:=1 to n do
if s[i]>s[k] then
exit(false);
exit(true);
end;
procedure main;
var
i:integer;
begin
tot:=0;
for i:=1 to n do
if check(i) then
begin
inc(tot);
ans[tot]:=i;
end;
end;
procedure print;
var
i:integer;
begin
for i:=1 to tot-1 do
write(ans[i],' ');
writeln(ans[tot]);
close(input);
close(output);
end;
begin
init;
main;
print;
end.