/// 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, type[12]; while(cin>>c && c!='*') { type[n]=c; if(c=='r') cin>>xl[n]>>yh[n]>>xh[n]>>yl[n]; else cin>>xl[n]>>yh[n]>>xh[n]; 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(type[i]=='r') { 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; } } else { double dist = sqrt((x-xl[i])*(x-xl[i]) + (y-yh[i])*(y-yh[i])); if(xh[i]>dist) { 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; }
Thursday, 9 April 2015
UVA 477 Points in Figures: Rectangles and Circles
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment