Attack on Titan (State compression), attacktitan

Source: Internet
Author: User

Attack on Titan (State compression), attacktitan
Attack on Titan

WL recently fell in love with a game called the mythical age, which contains a very powerful soldier-titanium, which can destroy a village without any effort. However, titanium has a weakness that it cannot cross the river. On one occasion, WL played with a map filled with rivers, where N villages and M rivers (each river can be regarded as a straight line across the map ). WL summoned k titanomachy in some locations in one breath. Now, WL wants to know which villages can be destroyed.

Input

There are multiple groups of input data.

Enter an integer T (T ≤ 10) in the first line to indicate the number of data groups.

The first act of each group of data contains three integers: N (N ≤ 50000), K (K ≤ 50000), and M (M ≤ 50), representing the number of villages, titanes, and rivers, respectively.

In the next N rows, two integers x and y (0 ≤ x, y ≤ 10 ^ 6) represent the coordinates of the village I.

In the next K line, two integers x and y (0 ≤ x, y ≤ 10 ^ 6) represent the coordinates of the I titanium.

Next, four integers x1, y1, x2, and y2 (0 ≤ x1, y1, x2, y2 ≤ 10 ^ 6) in each row of the M line represent the two points that the I-th river flows through, ensure that (x1, y1) and (x2, y2) do not overlap, ensure that the village and titanium are not on any river.

Output

N rows are output for each group of data. If the village I can be destroyed, 1 is output in row I; otherwise, 0 is output.

Sample Input
12 1 10 02 02 21 0 1 1
Sample Output
01
Source 13th Beijing Normal University Program Design Competition finals Author

Hwq

 

 

Record the location of each titanium relative to each river, and then judge the location of each village relative to the river, and use the state to compress the storage. Note that map <string, bool> is used, at the beginning, we used map <long, bool> to get the result WA... T ^ T. Today I am worried about various WA...

 

Reprinted please indicate the source: http://blog.csdn.net/u010579068/article/details/45606905

 

Question link: http://www.bnuoj.com/bnuoj/problem_show.php? Pid = 1, 49099

 

 

# Include <iostream> # include <stdio. h> # include <string. h> # include <stack> # include <queue> # include <map> # include <set> # include <vector> # include <math. h> # include <algorithm> using namespace std; # define ls 2 * I # define rs 2 * I + 1 # define up (I, x, y) for (I = x; I <= y; I ++) # define down (I, x, y) for (I = x; I> = y; I --) # define mem (a, x) memset (a, x, sizeof (a) # define w (a) while () # define LL long longconst double pi = acos (-1.0 );# Define N 50005 # define mod 19999997 const int INF = 0x3f3f3f3f; # define exp 1e-8struct Point {LL x, y; Point (LL x = 0, LL y = 0 ): x (x), y (y) {}// constructor for easy coding}; typedef Point Vector; // Vector is just the alias of Point. // Vector + Vector = Vector; vector + point = point Vector operator + (Vector A, Vector B) {return Vector (. x + B. x,. y + B. y);} // Point-Point = Vector inline Vector operator-(Point A, Point B) {return Vector (. x-B.x,. y-B.y);} inline bool Cross (Vector A, Vector B) {re Turn A. x * B. y> B. x * A. y? True: false;} inline bool judge (Point A, Point B, Point C) {return Cross (B-A, C-A);} map <string, bool> vis; point a [N], B [N], c [55] [2]; int main () {LL t, I, j; LL n, m, k; scanf ("% lld", & t); w (t --) {vis. clear (); scanf ("% lld", & n, & m, & k); up (I, 0, n-1) {scanf ("% lld", & a [I]. x, & a [I]. y);} up (I, 0 m-1) {scanf ("% lld", & B [I]. x, & B [I]. y);} up (I, 0, k-1) {scanf ("% lld", & c [I] [0]. x, & c [I] [0]. y, & c [I] [1]. x, & c [I] [1]. y);} up (I, 0, m-1) {string s = ""; up (j, 0, k-1) {if (judge (c [j] [0], c [j] [1], B [I]) s + = "1"; else s + = "0";} s + = ""; // printf ("s1 = % lld \ n", s); vis [s] = true;} up (I, 0, n-1) {string s = ""; up (j, 0, k-1) {if (judge (c [j] [0], c [j] [1], a [I]) s + = "1"; else s + = "0";} s + = ""; // printf ("s2 = % lld \ n", s ); if (vis [s] = true) printf ("1 \ n"); else printf ("0 \ n") ;}} 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.