您的位置:首页 > 其它

pku1468 Rectangles

2012-03-01 11:55 274 查看
这道题真是没法说,时间限制是5000ms,而且矩形数还少于5000,

O(n^2)枚举即可啊!!

View Code

program pku1468(input,output);
type
node    = record
x1,y1,x2,y2 : longint;
end;
var
a        : array[0..5001] of node;
answer,n : longint;
function cover(x,y :longint ):boolean;
begin
if (a[y].x1<=a[x].x1)and(a[x].x2<=a[y].x2) then
if (a[y].y1<=a[x].y1)and(a[x].y2<=a[y].y2) then
exit(true);
exit(false);
end; { cover }
procedure init;
var
i : longint;
begin
readln(n);
for i:=1 to n do
readln(a[i].x1,a[i].x2,a[i].y1,a[i].y2);
end; { init }
procedure main;
var
i,j : longint;
begin
answer:=0;
for i:=1 to n do
begin
for j:=1 to n do
if i<>j then
if cover(i,j) then
begin
inc(answer);
break;
end;
end;
end; { main }
begin
while not eof do
begin
init;
main;
writeln(answer);
end;
end.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: