POJ 2398 (two-point set)

Source: Internet
Author: User
Tags x2 y2

Language: Toy StorageTime Limit: 2000 MS Memory Limit: 65536 KTotal Submissions: 8137 Accepted: 3848Description In the rectangle (x1, y1) (x2, y2) there are n plates (to ensure the intersection with the upper and lower sides) and m points. The positions of plates and points are given, and the number of regions with the same number of points and multiple groups of Input data are obtained. each group of data starts with n m x1 y1 x2 y2. n (0 <n <= 5000) m (0 <m <= 5000 ). (x1, y1) is the coordinate in the upper left corner, (x2, y2) is the coordinate in the lower right corner. there are two numbers of Ui Li in the next n rows, indicating that the I-th board is (Ui, y1) (Li, y2 ). (ensure that the packets are not handed in ). next, the m behavior point coordinate Xj Yj (ensure that the data is not on the board) ends with 0. output the number of regions for each group of data in the same number of points: number of regions... (The number of points is 1 → n, and the number of regions is 0.) output is in this format. "Box" is output at the beginning of each group of data ". Sample Input5 6 0 10 60 03 14 36 810 1015 301 52 12 85 540 107 100 94 10 0 10 2040 020 4060 6080 1015 1025 1035 1045 1055 1065 1075 1085 1095 100 Sample Output0: 21: 12: 13: 14: 05: 1 0: 21: 22: 23: 24: 2Hint points on the side of the rectangle. sourceRocky Mountain 2003 is basically the same as POJ 2318 [cpp] # include <cstdio> # include <cstring> # include <cstdlib> # include <cctype> # include <iostream> # include <algorithm> # include <functional> using namespace std; # define MAXN (1000 + 10) // Board # define MAXM (1000 + 10) // Toy struct P {double x, y; P () {} P (int _ x, int _ y): x (_ x), y (_ y) {} friend istream & operator> (istream & cin, P & a) {cin>. x>. y; return cin ;}} a [MAXM]; struct V {double x, y; P s; V () {} V (P a, P B ): x (B. x-a.x), y. y-a.y), s (a) {} friend int operator * (const V a, const V B) {return. x * B. y-a.y * B. x ;}} c [MAXN]; int n, m, x1, y1, x2, y2, f [MAXM]; int cmp (V a, V B) {return. s. x <B. s. x;} void binary (int L, int R, int l, int r) {if (R-L = 1) {f [r-l + 1] ++; return;} int I = l, j = r, m = (l + r)> 1; V & M = c [(L + R)> 1]; do {while (I <= r & V (M. s, a [I]) * M <0) I ++; while (j> = l & V (M. s, a [j]) * M> 0) j --; if (I <= j) {swap (a [I], a [j]); I ++; j --;} while (I <= j); I --; j ++; binary (L, (L + R)> 1, l, I ); binary (L + R)> 1, R, j, r);} int main () {// freopen ("poj2398.in", "r", stdin ); while (scanf ("% d", & n, & m) = 2) {cout <"Box \ n"; memset (f, 0, sizeof (f); cin> x1> y2> x2> y1; for (int I = 1; I <= n; I ++) {int u, l; cin> u> l; c [I] = V (P (l, y1), P (u, y2 ));} c [0] = V (P (x1, y1), P (x1, y2); c [n + 1] = V (P (x2, y1 ), P (x2, y2); sort (c + 1, c + 1 + n, cmp); for (int I = 1; I <= m; I ++) cin> a [I]; binary (0, n + 1, 1, m); for (int I = 1; I <= m; I ++) if (f [I]) cout <I <":" <f [I] <endl;} return 0 ;}

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.