Points(翻译)

该问题描述了一个二维坐标系统中,对点进行增加、删除和查找操作的场景。输入包含一系列操作请求,要求编写程序来高效处理这些请求,特别是当请求量达到大规模时。输入包括点的坐标,输出是对特定区域内最左下角点的坐标。题目旨在考察数据结构和算法的设计能力,以应对大量查询的效率挑战。
摘要由CSDN通过智能技术生成

2022.2.16

题目网址:

https://codeforces.com/contest/19/problem/D

原题:

Points

 2000ms  262144K

描述:

Pete and Bob invented a new interesting game. Bob takes a sheet of paper and locates a Cartesian coordinate system on it as follows: point (0, 0) is located in the bottom-left corner, Ox axis is directed right, Oy axis is directed up. Pete gives Bob requests of three types:

  • add x y — on the sheet of paper Bob marks a point with coordinates (x, y). For each request of this type it's guaranteed that point (x, y) is not yet marked on Bob's sheet at the time of the request.
  • remove x y — on the sheet of paper Bob erases the previously marked point with coordinates (x, y). For each request of this type it's guaranteed that point (x, y) is already marked on Bob's sheet at the time of the request.
  • find x y — on the sheet of paper Bob finds all the marked points, lying strictly above and strictly to the right of point (x, y). Among these points Bob chooses the leftmost one, if it is not unique, he chooses the bottommost one, and gives its coordinates to Pete.

Bob managed to answer the requests, when they were 10, 100 or 1000, but when their amount grew up to 2·105, Bob failed to cope. Now he needs a program that will answer all Pete's requests. Help Bob, please!

输入:

The first input line contains number n (1 ≤ n ≤ 2·105) — amount of requests. Then there follow n lines — descriptions of the requests. add x y describes the request to add a point, remove x y — the request to erase a point, find x y — the request to find the bottom-left point. All the coordinates in the input file are non-negative and don't exceed 109.

输出:

For each request of type find x y output in a separate line the answer to it — coordinates of the bottommost among the leftmost marked points, lying strictly above and to the right of point (x, y). If there are no points strictly above and to the right of point (x, y), output -1.

翻译:

描述:

彼得和鲍勃发明了一个新的有趣的游戏。鲍勃带来了一张纸并且建立了一个笛卡尔坐标系:点(0,0)被建在左下角,Ox轴在右方,Oy轴在上方。彼得给鲍勃需要的三种类型:

加x y---鲍勃在这张纸上用坐标(x,y)标记了一个点。对于每个这个类型的需要确保点(x,y)没有标记在鲍勃已经标记的点处。

移除x y---鲍勃在这张纸上擦去已经标记的点(x,y)。对于每个这种类型的请求确保点(x,y)当时已经标记了。

找到x y---鲍勃发现所有已经标记的点在点(x,y)的右边。在鲍勃选择的这些点的最左边的一个,如果它不是唯一个点,那么他选择最低的一个,并把这个坐标给彼得。

鲍勃设法成功回答了这个问题,当他们是10,100或者1000时,但是当他们的数量增长到2*105的时候,鲍勃无法复制他们。现在他需要一个将回答所有彼得的需求的程序。请帮帮鲍勃。

输入:

第一行输入包含n个数字(1<=n<=2*105)---是需求的数量。然后接下来n行---是这些需求的描述。加x y这个需求是去加一个点x y,移除x y是去擦除一个点x y,找到x y是去找到最左下角的一个点。所有在输入数据里的坐标都是非负的,不超过10^9。

输出:

对于每个在单独的一行找到x y的类型需求的回答---在最左的标记的点中最下方的坐标,位于上方和点(x,y)右边。如果这里没有一个点在(x,y)的上方和右边,那么输出-1。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值