zoukankan      html  css  js  c++  java
  • 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.



  • 相关阅读:
    软工实践结对作业第二次
    团队展示
    软件工程结对作业
    软工实践第二次作业
    栈的初步学习
    课程作业四
    作业
    课程作业2
    博客汇总目录
    Mybatis-plus学习笔记,基于springboot
  • 原文地址:https://www.cnblogs.com/neverforget/p/2375288.html
Copyright © 2011-2022 走看看