| 记录编号 |
84908 |
评测结果 |
AAA |
| 题目名称 |
438.幻灯片排序 |
最终得分 |
100 |
| 用户昵称 |
srt09 |
是否通过 |
通过 |
| 代码语言 |
Pascal |
运行时间 |
0.000 s |
| 提交时间 |
2013-12-21 20:07:08 |
内存使用 |
0.17 MiB |
显示代码纯文本
program slides;
const
letter:array[1..26] of char=('A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z');
var
n,i,j,k,sum,deal:longint;
map:array[1..26,1..4] of longint;
data:array[1..26,1..2] of longint;
outo:array[1..26,1..27] of longint;
can:array[1..26] of boolean;
use:array[1..26] of longint;
ans:array[1..26] of longint;
procedure init;
begin
readln(n);
fillchar(outo,sizeof(outo),0);
fillchar(can,sizeof(can),false);
sum:=n;
deal:=0;
for i:=1 to n do
can[i]:=true;
for i:=1 to n do
readln(map[i,1],map[i,2],map[i,3],map[i,4]);
for i:=1 to n do
readln(data[i,1],data[i,2]);
end;
function search(x,y,xmin,xmax,ymin,ymax:longint):boolean;
begin
if x<xmin then exit(false);
if x>xmax then exit(false);
if y<ymin then exit(false);
if y>ymax then exit(false);
exit(true);
end;
procedure work;
begin
for i:=1 to n do
begin
for j:=1 to n do
if search(data[i,1],data[i,2],map[j,1],map[j,2],map[j,3],map[j,4]) then
begin
inc(outo[i,27]);
outo[i,j]:=1;
use[i]:=j;
end;
if outo[i,27]<>1 then
begin
can[i]:=false;
dec(sum);
end;
end;
while sum>0 do
begin
for i:=1 to n do
if can[i] then
begin
for j:=1 to n do
if outo[i,j]=1 then
begin
ans[j]:=i;
use[i]:=j;
end;
can[i]:=false;
outo[i,27]:=0;
outo[i,use[i]]:=0;
dec(sum);
inc(deal);
for k:=1 to n do
if outo[k,use[i]]=1 then
begin
dec(outo[k,use[i]]);
dec(outo[k,27]);
if outo[k,27]=1 then
begin
can[k]:=true;
inc(sum);
end;
end;
end;
end;
if deal<>n then
writeln('None')
else
for i:=1 to n do
writeln(letter[i],' ',ans[i]);
end;
begin
assign(input,'slides.in');
assign(output,'slides.out');
reset(input);
rewrite(output);
init;
work;
close(input);
close(output);
end.