CF1651D.Nearest Excluded Points
普及/提高-
通过率:0%
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∣ .
输入格式
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.
输出格式
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.
输入输出样例
输入#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