pku1468 Rectangles

这道题真是没法说,时间限制是5000ms,而且矩形数还少于5000,

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

View Code
 1 program pku1468(input,output);
2 type
3 node = record
4 x1,y1,x2,y2 : longint;
5 end;
6 var
7 a : array[0..5001] of node;
8 answer,n : longint;
9 function cover(x,y :longint ):boolean;
10 begin
11 if (a[y].x1<=a[x].x1)and(a[x].x2<=a[y].x2) then
12 if (a[y].y1<=a[x].y1)and(a[x].y2<=a[y].y2) then
13 exit(true);
14 exit(false);
15 end; { cover }
16 procedure init;
17 var
18 i : longint;
19 begin
20 readln(n);
21 for i:=1 to n do
22 readln(a[i].x1,a[i].x2,a[i].y1,a[i].y2);
23 end; { init }
24 procedure main;
25 var
26 i,j : longint;
27 begin
28 answer:=0;
29 for i:=1 to n do
30 begin
31 for j:=1 to n do
32 if i<>j then
33 if cover(i,j) then
34 begin
35 inc(answer);
36 break;
37 end;
38 end;
39 end; { main }
40 begin
41 while not eof do
42 begin
43 init;
44 main;
45 writeln(answer);
46 end;
47 end.



posted @ 2012-03-01 11:55  Codinginging  阅读(168)  评论(0编辑  收藏  举报