|
|||
Force FieldsIn the future, all cities will be protected by force fields. We say there is a safe passage between two cities if the force fields of the two cities intersect in at least one point. A group of cities is called a safe component if any two cities from the group are connected directly or indirectly by safe passages. A single city is always a safe component if the radius of the force field is not 0. Given the number n of the cities and their (x, y) coordinates, and assuming each city has a force field of the same radius, answer the following questions:
Input SpecificationThe first line of the input contains an integer n, the number of cities (1 ≤ n ≤ 1000). Each of the next n lines contains two integers xi and yi, the coordinates of ith city (0 ≤ xi, yi ≤ 2000, 0 ≤ i ≤ n – 1). The next line contains an integer m, the number of questions (1 ≤ m ≤ 400 000). Each of the next m lines starts with an integer t, the type of question.
Output SpecificationFor each of the m questions, output a line containing the answer to the question. For t = 0, answer Q1, and for t = 1, answer Q2. For Q2, if there is a safe passage between the two cities, output 1, otherwise 0. Sample Input
Output for Sample Input
|
|||
University of Debrecen; Faculty of Informatics; v. 09/30/2024 |