CF1651D.Nearest Excluded Points
普及+/提高
通过率:0%
时间限制:4.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are given n distinct points on a plane. The coordinates of the i-th point are (xi,yi).
For each point i, find the nearest (in terms of Manhattan distance) point with integer coordinates that is not among the given n points. If there are multiple such points — you can choose any of them.
The Manhattan distance between two points (x1,y1) and (x2,y2) is ∣x1−x2∣+∣y1−y2∣.
给你平面上的 n 个互不相同的点。第 i 个点的坐标为 (xi,yi)。
对每个点 i,找出一个曼哈顿距离(Manhattan distance)最近的、坐标均为整数且不在给定的 n 个点之中的点。若存在多个满足条件的点,则任选其一即可。
两点 (x1,y1) 与 (x2,y2) 之间的曼哈顿距离定义为 ∣x1−x2∣+∣y1−y2∣。
输入格式
The first line of the input contains one integer n (1≤n≤2⋅105) — the number of points in the set.
The next n lines describe points. The i-th of them contains two integers xi and yi (1≤xi,yi≤2⋅105) — coordinates of the i-th point.
It is guaranteed that all points in the input are distinct.
输入的第一行包含一个整数 n(1≤n≤2⋅105)—— 表示集合中点的个数。
接下来的 n 行描述这些点。其中第 i 行包含两个整数 xi 和 yi(1≤xi,yi≤2⋅105)—— 表示第 i 个点的坐标。
保证输入中所有点互不相同。
输出格式
Print n lines. In the i-th line, print the point with integer coordinates that is not among the given n points and is the nearest (in terms of Manhattan distance) to the i-th point from the input.
Output coordinates should be in range [−106;106]. It can be shown that any optimal answer meets these constraints.
If there are several answers, you can print any of them.
输出 n 行。在第 i 行中,输出一个整数坐标点,该点不在给定的 n 个点之中,且在曼哈顿距离意义下,是离输入中第 i 个点最近的点。
输出坐标的取值范围必须在 [−106,106] 内。可以证明:任意最优解均满足此约束。
若存在多个合法答案,输出其中任意一个即可。
输入输出样例
输入#1
6 2 2 1 2 2 1 3 2 2 3 5 5
输出#1
1 1 1 1 2 0 3 1 2 4 5 4
输入#2
8 4 4 2 4 2 2 2 3 1 4 4 2 1 3 3 3
输出#2
4 3 2 5 2 1 2 5 1 5 4 1 1 2 3 2
输入解题思路,AI测评打分。不知道怎么写?