CF44G.Shooting Gallery

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Berland amusement park shooting gallery is rightly acknowledged as one of the best in the world. Every day the country's best shooters master their skills there and the many visitors compete in clay pigeon shooting to win decent prizes. And the head of the park has recently decided to make an online version of the shooting gallery. During the elaboration process it turned out that the program that imitates the process of shooting effectively, is needed. To formulate the requirements to the program, the shooting gallery was formally described. A 3D Cartesian system of coordinates was introduced, where the X axis ran across the gallery floor along the line, along which the shooters are located, the Y axis ran vertically along the gallery wall and the positive direction of the Z axis matched the shooting direction. Let's call the XOY plane a shooting plane and let's assume that all the bullets are out of the muzzles at the points of this area and fly parallel to the Z axis. Every clay pigeon can be represented as a rectangle whose sides are parallel to X and Y axes, and it has a positive z-coordinate. The distance between a clay pigeon and the shooting plane is always different for every target. The bullet hits the target if it goes through the inner area or border of the rectangle corresponding to it. When the bullet hits the target, the target falls down vertically into the crawl-space of the shooting gallery and cannot be shot at any more. The targets are tough enough, that's why a bullet can not pierce a target all the way through and if a bullet hits a target it can't fly on. In input the simulator program is given the arrangement of all the targets and also of all the shots in the order of their appearance. The program should determine which target was hit by which shot. If you haven't guessed it yet, you are the one who is to write such a program.

贝尔兰游乐园的射击靶场被公认为是世界上最好的靶场之一。每天,该国最优秀的射手都在此精进技艺,而众多游客则通过飞碟射击比赛来赢取丰厚奖品。最近,靶场负责人决定开发一款在线版射击靶场。在开发过程中,人们发现需要一个能有效模拟射击过程的程序。为明确该程序的功能需求,人们对该射击靶场进行了形式化建模:引入了一个三维笛卡尔坐标系,其中 XX 轴沿射手所站位置所在的直线、水平延伸穿过靶场地板;YY 轴沿靶场墙面垂直向上;ZZ 轴正方向与射击方向一致。我们将 XOYXOY 平面称为“射击平面”,并假定所有子弹均从该平面上的某点射出,并沿平行于 ZZ 轴的方向飞行。每个飞碟可表示为一个边分别平行于 XX 轴和 YY 轴的矩形,且其 zz 坐标恒为正值。每个飞碟到射击平面的距离互不相同。若子弹穿过对应矩形的内部区域或边界,则视为命中目标。一旦被击中,该飞碟即垂直下落至靶场底部的检修空间,此后便不可再被击中。飞碟足够坚固,因此子弹无法穿透飞碟;一旦命中,子弹即停止运动,不再继续飞行。模拟程序的输入包含所有飞碟的布局信息以及所有射击事件(按其出现顺序给出)。程序需判定每次射击命中了哪一个飞碟。如果你尚未意识到——那么,编写这样一款程序的任务就落在了你的肩上。

输入格式

The first line contains an integer n (1 ≤ n ≤ 105) — the number of targets. Each of the subsequent n lines contains the description of a target. The target is described by five integers x__l, x__r, y__l, y__r, z, that determine it's location in space (0 ≤ x__l < x__r ≤ 107, 0 ≤ y__l < y__r ≤ 107, 0 < z ≤ 107). The next line contains an integer m (1 ≤ m ≤ 105), determining the number of shots. Then in m lines shots are described. Every shot is determined by the coordinates of a bullet on the shooting plane (x, y) (0 ≤ x, y ≤ 107, the coordinates of bullets are integers). The shots are given in the order of their firing. The intervals between shots are large enough, and a target falls very quickly, that's why assume that a falling target can not be an obstruction for all the shots following the one that hit it.

第一行包含一个整数 nn1n1051 \leq n \leq 10^5)——目标的数量。接下来的 nn 行每行描述一个目标。每个目标由五个整数 xl,xr,yl,yr,zx_l,\,x_r,\,y_l,\,y_r,\,z 描述,用于确定其在空间中的位置(0xl<xr1070 \leq x_l < x_r \leq 10^70yl<yr1070 \leq y_l < y_r \leq 10^70<z1070 < z \leq 10^7)。
下一行包含一个整数 mm1m1051 \leq m \leq 10^5),表示射击次数。随后 mm 行依次描述每次射击。每次射击由子弹在射击平面上的坐标 (x,y)(x,\,y) 确定(0x,y1070 \leq x,\,y \leq 10^7,子弹坐标均为整数)。射击按发射顺序给出。两次射击之间的时间间隔足够长,且目标倒下非常迅速,因此可假设:被击中的目标在后续所有射击中均不会构成遮挡。

输出格式

For every shot in the single line print the number of the target which the shot has hit, or 0, if the bullet did not hit any target. The targets are numbered starting from 1 in the order in which they were given in the input data.

对于每一发子弹,在单行中输出该子弹击中的目标编号;若子弹未击中任何目标,则输出 0。目标按输入数据中给出的顺序从 1 开始编号。

输入输出样例

  • 输入#1

    2
    1 4 1 4 1
    2 5 2 6 2
    4
    0 0
    3 3
    4 5
    3 5

    输出#1

    0
    1
    2
    0

输入解题思路,AI测评打分。不知道怎么写?

首页