아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Nice Set of Points

시간 제한1초메모리 제한256 MB

요약
최대 10000-N개의 정수 좌표 점을 추가해, 같은 x나 같은 y를 공유하는 이동만으로 두 점 사이 최단 경로 길이가 맨해튼 거리와 같아지도록 만든다.
난이도

보통10점 중 7점

유형
그래프, BFS, 구현
정답자
아직 제출이 없습니다

문제

Consider a set of points. You can move directly between two points if their x-coordinates are the same or their y-coordinates are the same. A set of points is called nice if for any two points in the set, the length of the shortest (direct or indirect) path is equal to the manhattan distance between them.

You are given NN points. The ii-th point is at (x_i,y_i)(x\_i, y\_i).

You are allowed to add up to 10000−N10000 - N points. Convert the given set of points into a nice set.

입력

NN
x_1x\_1  y_1y\_1
x_2x\_2 y_2y\_2
⋮\vdots
x_Nx\_N y_Ny\_N

출력

Let M(0≤M≤10000−N)M (0 \leq M \leq 10000 - N) be the number of added points, and (s_1,t_1),…,(s_M,t_M)(s\_1, t\_1), \ldots, (s\_M, t\_M) be their coordinates. After adding these MM points to the set, you get N+MN + M points. These N+MN+M points must be pairwise distinct, and this set must be nice. The coordinates must be integers.

Output the answer in the following format.

MM
s_1s\_1 t_1t\_1
s_2s\_2 t_2t\_2
⋮\vdots
s_Ns\_N t_Mt\_M

If there are multiple possible solutions, output any.

제한

  • 2≤N≤10002 \leq N \leq 1000
  • 1≤x_i,y_i≤10001 \leq x\_i, y\_i \leq 1000
  • The points are pairwise distinct.
  • Under these constraints, it is guaranteed that at least one solution exists.
  • All values in the input are integers.

힌트

In Sample 1, if you add (1,2)(1, 2), you can move between (1,1)(1, 1) and (2,2)(2, 2) via (1,2)(1, 2).

예제3

  1. 예제 1

    입력
    2
    1 1
    2 2
    
    예상 출력
    1
    1 2
    
  2. 예제 2

    입력
    4
    1 1
    2 2
    3 4
    4 3
    
    예상 출력
    4
    1 2
    3 2
    3 3
    4 4
    
  3. 예제 3

    입력
    7
    2 4
    3 2
    4 6
    5 1
    6 5
    7 3
    8 7
    
    예상 출력
    15
    3 6
    8 5
    2 2
    7 5
    2 5
    6 6
    3 1
    5 6
    6 2
    6 1
    7 1
    7 2
    2 3
    6 7
    2 6