300442: CF84C. Biathlon

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Biathlon

题意翻译

也许很多人都听说世界冬季两项锦标赛已经结束了。虽然我们的英雄瓦莱拉本人并没有出席这一壮观的活动,只是在电视上观看了比赛,但这让他非常兴奋,他决定报名参加一个冬季两项赛部分。 当然,铁人两项作为任何一项运动,在实践中都证明是非常困难的。这需要很多时间和努力。锻炼,锻炼,和锻炼,-这是等待瓦莱拉的方式,他在冬季两项运动的伟大成就。 至于训练,你们可能都知道,每个专业的冬季两项运动员都应该快速滑雪,并在射击场精确射击。只有在这种情况下,你才能希望成功,因为跑步和射击是两个主要组成部分的冬季两项。瓦莱拉在滑雪训练中一直很努力,这也是他跑得很快的原因,但是他的射门准确度却没有什么值得称道的。 在瓦莱拉准备参加比赛的两项基础上,有一个巨大的步枪射程,有$n$个目标。每个目标都有一个圆的形状,每个圆的中心都位于$Ox$轴上。在上一次训练中,瓦莱拉总共投了$m$球。为了让他更容易地监控自己的结果,一位相当有名的程序员(当然是你)被委托编写一个程序,该程序将显示瓦莱拉击中了多少目标。更具体地说,对于每个目标,程序必须打印第一次成功射击的次数(在目标中),如果没有击中,则打印$-1$。如果射击在圆圈内或其边界上,则视为击中目标。瓦莱拉指望着你,也许,多亏了你,他总有一天会赢得国际比赛。 输入文件的第一行包含整数$n(1\leq n\leq 10^{4})$,这是目标数。接下来的$n$行包含目标的描述。每个目标都是一个圆,其中心位于$Ox$轴上。每个圆由其中心$x$的坐标和半径$r(1\leq r\leq 1000)$给出。可以保证两个目标不会重合、相交或相互嵌套,但它们可以相互接触。 下一行包含整数$m ( 1\leq m\leq 2\times 10^{5})$ 这是拍摄的次数。接下来的$m$行包含快照的描述,快照是平面上的点,由坐标$x$和$y$给出$( -2\times 10^{4}\leq x,y\leq 2\times 10^{4})$ 输入的所有数字都是整数。 目标和射击按输入顺序从一开始编号。 在第一行打印一个数字,瓦莱拉击中的目标数。在第二行为每个目标打印第一次击中的数字,如果不存在该数字,则打印“-1”(不带引号)。用空格分隔数字。

题目描述

Perhaps many have heard that the World Biathlon Championship has finished. Although our hero Valera was not present at this spectacular event himself and only watched it on TV, it excited him so much that he decided to enroll in a biathlon section. Of course, biathlon as any sport, proved very difficult in practice. It takes much time and effort. Workouts, workouts, and workouts, — that's what awaited Valera on his way to great achievements in biathlon. As for the workouts, you all probably know that every professional biathlete should ski fast and shoot precisely at the shooting range. Only in this case you can hope to be successful, because running and shooting are the two main components of biathlon. Valera has been diligent in his ski trainings, which is why he runs really fast, however, his shooting accuracy is nothing to write home about. On a biathlon base where Valera is preparing for the competition, there is a huge rifle range with $ n $ targets. Each target have shape of a circle, and the center of each circle is located on the $ Ox $ axis. At the last training session Valera made the total of $ m $ shots. To make monitoring of his own results easier for him, one rather well-known programmer (of course it is you) was commissioned to write a program that would reveal how many and which targets Valera hit. More specifically, for each target the program must print the number of the first successful shot (in the target), or "-1" if this was not hit. The target is considered hit if the shot is inside the circle or on its boundary. Valera is counting on you and perhaps, thanks to you he will one day win international competitions.

输入输出格式

输入格式


The first line of the input file contains the integer $ n $ ( $ 1<=n<=10^{4} $ ), which is the number of targets. The next $ n $ lines contain descriptions of the targets. Each target is a circle whose center is located on the $ Ox $ axis. Each circle is given by its coordinate of the center $ x $ ( $ -2·10^{4}<=x<=2·10^{4} $ ) and its radius $ r $ ( $ 1<=r<=1000 $ ). It is guaranteed that no two targets coincide, intersect or are nested into each other, but they can touch each other. The next line contains integer $ m $ ( $ 1<=m<=2·10^{5} $ ), which is the number of shots. Next $ m $ lines contain descriptions of the shots, which are points on the plane, given by their coordinates $ x $ and $ y $ ( $ -2·10^{4}<=x,y<=2·10^{4} $ ). All the numbers in the input are integers. Targets and shots are numbered starting from one in the order of the input.

输出格式


Print on the first line a single number, the number of targets hit by Valera. Print on the second line for each of the targets the number of its first hit or "-1" (without quotes) if this number does not exist. Separate numbers with spaces.

输入输出样例

输入样例 #1

3
2 1
5 2
10 1
5
0 1
1 3
3 0
4 0
4 0

输出样例 #1

2
3 3 -1 

输入样例 #2

3
3 2
7 1
11 2
4
2 1
6 0
6 4
11 2

输出样例 #2

3
1 2 4 

Input

题意翻译

也许很多人都听说世界冬季两项锦标赛已经结束了。虽然我们的英雄瓦莱拉本人并没有出席这一壮观的活动,只是在电视上观看了比赛,但这让他非常兴奋,他决定报名参加一个冬季两项赛部分。 当然,铁人两项作为任何一项运动,在实践中都证明是非常困难的。这需要很多时间和努力。锻炼,锻炼,和锻炼,-这是等待瓦莱拉的方式,他在冬季两项运动的伟大成就。 至于训练,你们可能都知道,每个专业的冬季两项运动员都应该快速滑雪,并在射击场精确射击。只有在这种情况下,你才能希望成功,因为跑步和射击是两个主要组成部分的冬季两项。瓦莱拉在滑雪训练中一直很努力,这也是他跑得很快的原因,但是他的射门准确度却没有什么值得称道的。 在瓦莱拉准备参加比赛的两项基础上,有一个巨大的步枪射程,有$n$个目标。每个目标都有一个圆的形状,每个圆的中心都位于$Ox$轴上。在上一次训练中,瓦莱拉总共投了$m$球。为了让他更容易地监控自己的结果,一位相当有名的程序员(当然是你)被委托编写一个程序,该程序将显示瓦莱拉击中了多少目标。更具体地说,对于每个目标,程序必须打印第一次成功射击的次数(在目标中),如果没有击中,则打印$-1$。如果射击在圆圈内或其边界上,则视为击中目标。瓦莱拉指望着你,也许,多亏了你,他总有一天会赢得国际比赛。 输入文件的第一行包含整数$n(1\leq n\leq 10^{4})$,这是目标数。接下来的$n$行包含目标的描述。每个目标都是一个圆,其中心位于$Ox$轴上。每个圆由其中心$x$的坐标和半径$r(1\leq r\leq 1000)$给出。可以保证两个目标不会重合、相交或相互嵌套,但它们可以相互接触。 下一行包含整数$m ( 1\leq m\leq 2\times 10^{5})$ 这是拍摄的次数。接下来的$m$行包含快照的描述,快照是平面上的点,由坐标$x$和$y$给出$( -2\times 10^{4}\leq x,y\leq 2\times 10^{4})$ 输入的所有数字都是整数。 目标和射击按输入顺序从一开始编号。 在第一行打印一个数字,瓦莱拉击中的目标数。在第二行为每个目标打印第一次击中的数字,如果不存在该数字,则打印“-1”(不带引号)。用空格分隔数字。

加入题单

上一题 下一题 算法标签: