CF1651D.Nearest Excluded Points

普及/提高-

通过率:0%

AC君温馨提醒

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

题目描述

You are given nn distinct points on a plane. The coordinates of the ii -th point are (xi,yi)(x_i, y_i) .

For each point ii , find the nearest (in terms of Manhattan distance) point with integer coordinates that is not among the given nn points. If there are multiple such points — you can choose any of them.

The Manhattan distance between two points (x1,y1)(x_1, y_1) and (x2,y2)(x_2, y_2) is x1x2+y1y2|x_1 - x_2| + |y_1 - y_2| .

输入格式

The first line of the input contains one integer nn ( 1n21051 \le n \le 2 \cdot 10^5 ) — the number of points in the set.

The next nn lines describe points. The ii -th of them contains two integers xix_i and yiy_i ( 1xi,yi21051 \le x_i, y_i \le 2 \cdot 10^5 ) — coordinates of the ii -th point.

It is guaranteed that all points in the input are distinct.

输出格式

Print nn lines. In the ii -th line, print the point with integer coordinates that is not among the given nn points and is the nearest (in terms of Manhattan distance) to the ii -th point from the input.

Output coordinates should be in range [106;106][-10^6; 10^6] . 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
首页