Ultraviolet A 12537 Radiation

Source: Internet
Author: User

Nuclear power plants (NPP) are a blessing and curse of modern civilization. NPPs have some risks but still it is one of the cheapest ways to produce Atomicity in the developed world. in this problem we will discuss a situation related to two nuclear plants, which are not far away from each other. figure 1: Two Nuclear Power Plants. houses at (81, 49) and (77,33) are at high risk from both the plants. we will describe the entire scenario in a flat land, so two-dimen1_cartesian coordinate system is used to denote each location. letsassume that the coordinate of the two nuclear power plants are (ax, ay) and (bx, ). houses that are located within distance R1 (aggressive) of the power plant at (ax, ay) are under high risk of radiation. similarly, houses that are located within distance R2 (aggressive) of the power plant at (bx, by) are under high risk of radiation. so the authorities of power plant 1 and power plant 2 distribute special protective equipments to the houses that are within radius (aggressive) R1 and R2 of the respective power plants. as a result each of the houses that are endangered by both the plants actually receive two sets of equipments to protect their house, however only one set is enough for full protection. houses that are outside the high-risk area are under low risk of radiation but they do not receive any protective equipment due to budget constraints. however, each owner of the houses that have two sets of protective equipments gives away one set of equipment to the owner of a house that has none. still, some houses in the low-risk area remain un-protected. given the location of the houses and the values of ax, ay, bx, by and possible values of R1 and R2 your job is to find out the number of houses that are without protective equipments for each pair of values of R1 and R2. Input The input file contains at most 3 test cases. the description of each test case is given below: A test case starts with a line containing a positive integer N (0 <N ≤ 200000) that denotes the number of houses that are under either low risk or high risk of radiation. each of the next N lines contains two integers xi, yi (0 ≤xi, yi ≤ 20000) that denotes the coordinate of the I-thhouse. no two houses are at the same location. the next line contains five integers ax, ay, bx, by and q (0 ≤ ax, ay, bx, by ≤ 20000, 0 <q ≤ 20000 ). the meaning of ax, ay, bx and by are given in the problem statement. here q denotes the total number of query. each of the next q lines contains two integers, which denote the values of R1 and R2 (0 <R1, R2 ≤13000) respectively. A line containing a single zero terminates input. this line shoshould not be processed. outputFor each test case produce q + 1 lines of output. the first line is the serial of output. for each query (given value of R1 and R2) determine how to handle houses in the low risk region remains without protective equipment. you may consider using faster IO as judge input file is large. sample Input | Output for Sample Input11 95 75 27 6 93 5 124 13 34 49 65 61 81 49 77 33 110 50 91 22 110 25 25 57 42 97 36 2 31 25 25 25 0 Case 1: 2 2 Note: First query in the sample input corresponds to Figure 1. question: n, given n points, the coordinates of the coordinate circle 1, the coordinate circle 2, the number of times the radius of the circle 1, the radius of the circle 2, the question: for each question, find (points not on the circle-points in the coincident part of the 2 circle) // note that when the answer <0 outputs 0: first, convert the meaning of the question, we can think of it as finding n-(point on circle 1)-(point on circle 2) because all points are fixed, so (point on circle 1) => DIS (point, Center 1) <= R1 only needs to find the number of all vertices that satisfy the above inequality points to sort all vertices in descending order (to the distance from Center 1, in the p1 array, remove vertices with the same dis in p1 and store them in the k1 array, k1.num indicates that there are k1.num points at the distance <= k1.dis and k1.num points at the second point find the largest k1.num of k1.dis <= R1, that is (points on circle 1) same operation on vertices on circle 2

# Include <iostream> # include <string> # include <cstring> # include <algorithm> # include <cstdio> # include <cctype> # include <queue> # include <stdlib. h> # include <cstdlib> # include <math. h >#include <set ># include <vector> # define inf 2000000 # define N 200200 using namespace std; struct node {int x, y; int dis; bool operator <(const node & a) const {return. dis> dis;} p1 [N], p2 [N], r1, r2; struct kk {int dis, num;} k1 [N], k2 [N]; int kn1, kn2; int R1, R2, sum1, sum2, n; int DIS (node a, node B) {return (. x-b.x) * (. x-b.x) +. y-b.y) * (. y-b.y);} int erfen1 (int l, int r, int d) {if (l = R-1 & k1 [l]. dis <= d & k1 [r]. dis> d) return k1 [l]. num; int mid = (l + r)> 1; if (k1 [mid]. dis> d) return erfen1 (l, mid, d); if (k1 [mid]. dis <d) return erfen1 (mid, r, d); if (k1 [mid]. dis = d) return k1 [mid]. num;} int erfen2 (int l, int r, int d) {if (l = R-1 & k2 [l]. dis <= d & k2 [r]. dis> d) return k2 [l]. num; int mid = (l + r)> 1; if (k2 [mid]. dis> d) return erfen2 (l, mid, d); if (k2 [mid]. dis <d) return erfen2 (mid, r, d); if (k2 [mid]. dis = d) return k2 [mid]. num;} void quchong () {// p array de-duplicated to obtain k array int I; for (I = 1; I <= n; I ++) {if (p1 [I]. dis = p1 [I-1]. dis) k1 [kn1]. num ++; else {kn1 ++; k1 [kn1]. dis = p1 [I]. dis; k1 [kn1]. num = 1 + k1 [kn1-1]. num;} if (p2 [I]. dis = p2 [I-1]. dis) k2 [kn2]. num ++; else {kn2 ++; k2 [kn2]. dis = p2 [I]. dis; k2 [kn2]. num = 1 + k2 [kn2-1]. num ;}} int main () {int I, j, query, Cas = 1; p1 [0]. dis = p2 [0]. dis =-1; // deduplicated boundary while (scanf ("% d", & n), n) {for (I = 1; I <= n; I ++) scanf ("% d", & p1 [I]. x, & p1 [I]. y), p2 [I] = p1 [I]; scanf ("% d", & r1.x, & r1.y, & r2.x, & r2.y, & query); for (I = 1; I <= n; I ++) p1 [I]. dis = DIS (p1 [I], r1), p2 [I]. dis = DIS (p2 [I], r2); sort (p1 + 1, p1 + n + 1); sort (p2 + 1, p2 + n + 1 ); kn1 = kn2 = 0; quchong (); k1 [0]. dis = k2 [0]. dis =-1; // The required boundary condition k1 [0]. num = k2 [0]. num = 0; k1 [kn1 + 1]. dis = k2 [kn2 + 1]. dis = inf; // The required boundary condition printf ("Case % d: \ n", Cas ++); while (query --) {scanf ("% d", & R1, & R2); sum1 = erfen1 (1, kn1, R1 * R1); sum2 = erfen2 (1, kn2, r2 * R2); int ans = n-sum1-sum2; if (ans <0) ans = 0; printf ("% d \ n", ans) ;}} return 0 ;} /* 1195 7527 693 5124 1334 4965 6181 4977 33110 5091 22110 2557 42 97 36 231 2525 25151 12 12 23 3 4 45 510 515 51 02 03 04 05 06 010 020000 2000010 0 5 27 18 1ans: 228 3 */

 


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.