poj 1468 Rectangles

水题,直接暴力:

View Code
#include<iostream>

#include<cstdio>

#include<cstdlib>

#include<algorithm>

#include<cmath>

#include<queue>

#include<set>

#include<map>

#include<cstring>

#include<vector>

#include<string>

#define LL long long

using namespace std;

class Rec

{

public:

      double x1,y1,x2,y2;

}p[5024];

bool judge( Rec a, Rec b )

{

    if( b.x1<=a.x1 && b.x2>=a.x2 )

        if( b.y1 <= a.y1 && b.y2 >= a.y2 )

            return true;

    return false;

}

int Solve( int n )

{

    int sum = 0;

    for( int i = 0 ; i < n ; i ++ )

    {

        for( int j = 0 ; j < n ; j ++ )

        {

            if( j != i && judge( p[i],p[j] ))

            {

                sum ++;

                break;

           }

        }    

    }

    return sum;

}

int main(  )

{

    int n;

    while( scanf( "%d",&n )==1 )

    {

         for( int i = 0 ; i < n ; i ++ )

         {

             scanf( "%lf%lf%lf%lf",&p[i].x1,&p[i].x2,&p[i].y1,&p[i].y2 );        

         }    

         printf( "%d\n",Solve( n ) );

    }

    //system( "pause" );

    return 0;

}

你可能感兴趣的:(poj)