Bzoj 1199 Hnoi 2005 Tom's Game Computational geometry

Source: Internet
Author: User

Main topic

Give a number of graphs, some of which are rectangles, and the rest are round. There are some points that ask how many graphs each point is in.

Ideas

The topic does not write the data range, actually is 25w. Dare O (n^2) violence? Yes, the problem is violence. You just need to deal with one-dimensional coordinates in binary and then the second dimension of violence.

CODE
#define _crt_secure_no_warnings#include <cmath>#include <cstdio>#include <cstring>#include <iostream>#include <algorithm>#define MAX 250010using namespace STD;structpoint{Doublex, y; Point (Double_,Double__): X (_), Y (__) {} point () {}BOOL operator< (ConstPoint &a)Const{returnx < a.x; }voidRead () {scanf("%LF%LF", &x,&y); }};inline DoubleCalc (ConstPoint &a,ConstPoint &b) {return sqrt((a.x-b.x) * (a.x-b.x) + (A.Y-B.Y) * (A.Y-B.Y));struct_point:point{intID;} Point[max];intAns[max];intgraphs,points;structsquare{Point P1,p2;voidRead () {DoubleX1,y1,x2,y2;scanf("%LF%LF%LF%LF", &x1,&y1,&x2,&y2);        P1 = Point (min (x1,x2), Min (y1,y2));    P2 = Point (Max (X1,X2), Max (y1,y2)); }BOOLInRange (DoubleY) {returnY > P1.y && y < p2.y; }voidCount () {intStart = Upper_bound (Point +1, point + points +1, p1)-point;intEnd = Lower_bound (Point +1, point + points +1, p2)-point-1; for(inti = start; I <= end; ++i)if(InRange (POINT[I].Y)) ++ans[point[i].id]; }}square[max];structcircle{point P;DoubleRvoidRead () {p.read ();scanf("%LF", &r); }BOOLInRange (ConstPoint &a) {returnCalc (a,p) < R; }voidCount () {intStart = Upper_bound (Point +1, point + points +1, Point (P.x-r,0))-point;intEnd = Lower_bound (Point +1, point + points +1, point (p.x + R,0))-Point-1; for(inti = start; I <= end; ++i)if(InRange (Point[i])) ++ans[point[i].id]; }}circle[max];intSquares,circles;Chars[Ten];intMain () {Cin>> graphs >> points; for(inti =1; I <= graphs; ++i) {scanf('%s ', s);if(s[0] ==' R ') Square[++squares]. Read ();ElseCircle[++circles].    Read (); } for(inti =1; I <= points; ++i) {Point[i].        Read ();    Point[i].id = i; } sort (Point +1, point + points +1); for(inti =1; I <= squares; ++i) Square[i]. Count (); for(inti =1; I <= circles; ++i) Circle[i]. Count (); for(inti =1; I <= points; ++i)printf("%d\n", Ans[i]);return 0;}

Bzoj 1199 Hnoi 2005 Tom's Game Computational geometry

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.