比赛 |
2009暑期培训 |
评测结果 |
EEEEEEEEEE |
题目名称 |
速配游戏(无数据) |
最终得分 |
0 |
用户昵称 |
maxiem |
运行时间 |
0.000 s |
代码语言 |
Pascal |
内存使用 |
0.00 MiB |
提交时间 |
2009-07-09 10:10:11 |
显示代码纯文本
program match;
var
min,n,i,j,k,r,win:integer;
f:boolean;
m:array [1..1000,1..1000] of integer;
w:array [1..1000,1..1000] of integer;
q:array [1..1000,1..1000] of integer;
mc:array [1..1000] of integer;
qn:array [1..1000] of integer;
function getqn:boolean;
begin
getqn:=True;
for i:=1 to n do if qn[i]<>1 then begin
getqn:=false;
break;
end;
end;
begin
fillchar (m,sizeof(m),0);
fillchar (n,sizeof(n),0);
fillchar (mc,sizeof(mc),0);
assign (input,'match.in');
reset (input);
readln (n);
for i:=1 to n do begin
for j:=1 to n do read (m[i,j]);
mc[i]:=1;
readln;
end;
for i:=1 to n do begin
for j:=1 to n do read (w[i,j]);
readln;
end;
close (input);
assign (output,'match.out');
rewrite (output);
f:=false;
while not(f) do begin
fillchar (q,sizeof(q),0);
fillchar (qn,sizeof(qn),0);
for i:=1 to n do begin
r:=m[i,mc[i]];
inc(qn[r]);
q[r,qn[r]]:=i;
end;
f:=getqn;
if not(f) then for i:=1 to n do begin
min:=maxint;
for k:=1 to qn[i] do for j:=1 to n do if (q[i,k]=w[i,j]) and (j<min) then begin
win:=q[i,k];
min:=j;
end;
for j:=1 to qn[i] do if q[i,j]<>win then inc(mc[q[i,j]]);
end;
end;
for i:=1 to n do writeln (m[i,mc[i]]);
close (output);
end.