Thursday, 9 April 2015

UVA 476 Points in Figures: Rectangles

///     Raihan Ruhin
///     CSE, Jahangirnagar University.
///     Dhaka-Bangladesh.
///     id: raihanruhin (topcoder / codeforces / codechef / hackerrank / uva / uvalive / spoj), 3235 (lightoj)
///     mail: raihanruhin@ (yahoo / gmail / facebook)
///     blog: ruhinraihan.blogspot.com

#include<bits/stdc++.h>
using namespace std;

#define SET(a) memset(a,-1,sizeof(a))
#define CLR(a) memset(a,0,sizeof(a))
#define PI acos(-1.0)

#define MOD 1000000007
#define MX 100010


int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);
    int n=0, tc, kk=1;
    double xl[12], yh[12], xh[12], yl[12], x, y;
    string s;
    char c;
    while(cin>>c && c!='*')
    {
        cin>>xl[n++]>>yh[n]>>xh[n]>>yl[n];
    }
    int cnt=1;
    while(cin>>x>>y && !(x==9999.9 && y==9999.9))
    {
        bool chk=false;
        for(int i=0;i<n;i++)
            if(x>xl[i] && x<xh[i] && y>yl[i] && y<yh[i])
            {
                cout<<"Point "<<cnt<<" is contained in figure "<<i+1<<"\n";
                chk=true;
            }
        if(!chk)
            cout<<"Point "<<cnt<<" is not contained in any figure\n";
        cnt++;
    }
return 0;
}

No comments:

Post a Comment