LaLa and Magic Circle (LaLa Version)

아직 제출이 없습니다시간 제한2초메모리 제한1024 MB

문제

LaLa\color{blue}{\text{LaLa}} has a pile of magic\color{red}{\text{m}} \color{brown}{\text{a}} \color{orange}{\text{g}} \color{blue}{\text{i}} \color{magenta} {\text{c}} circles in her laboratory.

A magic\color{red}{\text{m}} \color{brown}{\text{a}} \color{orange}{\text{g}} \color{blue}{\text{i}} \color{magenta} {\text{c}} circle can be represented as a simple polygon drawn with special ink, and is usable if and only if it is convex. i.e. all of its internal angles are equal or less than π\pi.

LaLa\color{blue}{\text{LaLa}} plans to turn every magic\color{red}{\text{m}} \color{brown}{\text{a}} \color{orange}{\text{g}} \color{blue}{\text{i}} \color{magenta} {\text{c}} circle into a usable one. However, it may lose all its magic\color{red}{\text{m}} \color{brown}{\text{a}} \color{orange}{\text{g}} \color{blue}{\text{i}} \color{magenta} {\text{c}}al power if done incorrectly. Thankfully, LaLa\color{blue}{\text{LaLa}} has the perfect magic\color{red}{\text{m}} \color{brown}{\text{a}} \color{orange}{\text{g}} \color{blue}{\text{i}} \color{magenta} {\text{c}}al tool for that.

The tool works as follows. When you toss in a magic\color{red}{\text{m}} \color{brown}{\text{a}} \color{orange}{\text{g}} \color{blue}{\text{i}} \color{magenta} {\text{c}} circle, if it's usable, it reports that it is. Otherwise, it takes two distinct points uu and vv such that

  • uu and vv lie on the boundary of the convex hull of the magic\color{red}{\text{m}} \color{brown}{\text{a}} \color{orange}{\text{g}} \color{blue}{\text{i}} \color{magenta} {\text{c}} circle, and
  • none of the points on the path from uu to vv through the boundary of the magic\color{red}{\text{m}} \color{brown}{\text{a}} \color{orange}{\text{g}} \color{blue}{\text{i}} \color{magenta} {\text{c}} circle in counterclockwise order lie on the boundary of the convex hull of the magic\color{red}{\text{m}} \color{brown}{\text{a}} \color{orange}{\text{g}} \color{blue}{\text{i}} \color{magenta} {\text{c}} circle, except for uu and vv.

And then it rotates the uu-vv path by π\pi around the midpoint of uu and vv. In other words, for each point ww on the uu-vv path, ww becomes u+vwu+v-w where the addition is done coordinate-wise over the two dimensional coordinate system over the paper the magic\color{red}{\text{m}} \color{brown}{\text{a}} \color{orange}{\text{g}} \color{blue}{\text{i}} \color{magenta} {\text{c}} circle is drawn on. Note that the result of this modification is also a simple polygon.

LaLa\color{blue}{\text{LaLa}} got annoyed by how long it takes to convert them. In order to finish and take a nap ASAP, LaLa\color{blue}{\text{LaLa}} made the following observations.

  1. A magic\color{red}{\text{m}} \color{brown}{\text{a}} \color{orange}{\text{g}} \color{blue}{\text{i}} \color{magenta} {\text{c}} circle always turns into a usable one within a finite number of applications of the tool.
  2. The set of points on the final magic\color{red}{\text{m}} \color{brown}{\text{a}} \color{orange}{\text{g}} \color{blue}{\text{i}} \color{magenta} {\text{c}} circle is independent of the intermediate modifications. In other words, the shape and location of the final magic\color{red}{\text{m}} \color{brown}{\text{a}} \color{orange}{\text{g}} \color{blue}{\text{i}} \color{magenta} {\text{c}} circle is a function of the initial magic\color{red}{\text{m}} \color{brown}{\text{a}} \color{orange}{\text{g}} \color{blue}{\text{i}} \color{magenta} {\text{c}} circle.

Therefore, LaLa\color{blue}{\text{LaLa}} doesn't have to manually turn magic\color{red}{\text{m}} \color{brown}{\text{a}} \color{orange}{\text{g}} \color{blue}{\text{i}} \color{magenta} {\text{c}} circles into usable ones with the tool. Instead, LaLa\color{blue}{\text{LaLa}} will compute the usable magic\color{red}{\text{m}} \color{brown}{\text{a}} \color{orange}{\text{g}} \color{blue}{\text{i}} \color{magenta} {\text{c}} circle that can be made from the initial magic\color{red}{\text{m}} \color{brown}{\text{a}} \color{orange}{\text{g}} \color{blue}{\text{i}} \color{magenta} {\text{c}} circle by a sequence of modifications by the tool and modify it in one go.

Write a program to help LaLa\color{blue}{\text{LaLa}} compute the final magic\color{red}{\text{m}} \color{brown}{\text{a}} \color{orange}{\text{g}} \color{blue}{\text{i}} \color{magenta} {\text{c}} circle so that she can go take a nap.

입력

The input is given in the following format:

NN

x_0x\_0 y_0y\_0

x_0x\_0 y_0y\_0

\vdots

x_N1x\_{N-1} y_N1y\_{N-1}

where the initial magic\color{red}{\text{m}} \color{brown}{\text{a}} \color{orange}{\text{g}} \color{blue}{\text{i}} \color{magenta} {\text{c}} circle is the union of NN line segments connecting points (x_i,y_i)(x\_i, y\_i) and (x_(i+1modN),y_(i+1modN))(x\_{(i+1 \bmod N)}, y\_{(i+1 \bmod N)}) for all integers 0i<N0 \le i < N.

The input satisfies the following constraints:

  • All numbers in the input are integers.
  • 3N100,0003 \le N \le 100\\,000
  • 0x_i300,0000 \le x\_i \le 300\\,000 and 0y_i300,0000 \le y\_i \le 300\\,000 for all integers 0i<N0 \le i < N.
  • x_ix_jx\_i \ne x\_j or y_iy_jy\_i \ne y\_j for all integers 0i<j<N0 \le i < j < N.
  • The input defines a counterclockwise traversal of the boundary of a simple polygon. In particular, it does not intersect with itself.

출력

The output should be in the following format:

MM

z_0z\_0 w_0w\_0

z_1z\_1 w_1w\_1

\vdots

z_M1z\_{M-1} w_M1w\_{M-1}

where the final usable magic\color{red}{\text{m}} \color{brown}{\text{a}} \color{orange}{\text{g}} \color{blue}{\text{i}} \color{magenta} {\text{c}} circle is the union of MM line segments connecting points (z_i,w_i)(z\_i, w\_i) and (z_(i+1modM),w_(i+1modM))(z\_{(i+1 \bmod M)}, w\_{(i+1 \bmod M)}) for all integers 0i<M0 \le i < M,

The output should satisfy the following constraints:

  • All the numbers in the output are integers.
  • The point (z_0,w_0)(z\_0, w\_0) is lexicographically smaller than the point (z_i,w_i)(z\_i, w\_i) for all integers 1i<M1 \le i < M. i.e. (z_0<z_iz\_0 < z\_i) or (z_0=z_iz\_0 = z\_i and w_0<w_iw\_0 < w\_i).
  • Points (z_i,w_i)(z\_i, w\_i), (z_(i+1modM),w_(i+1modM))(z\_{(i + 1 \bmod M)}, w\_{(i + 1 \bmod M)}), and (z_(i+2modM),w_(i+2modM))(z\_{(i + 2 \bmod M)}, w\_{(i + 2 \bmod M)}) are not collinear for all integers 0i<M0 \le i < M.
  • The output defines a counterclockwise traversal of the boundary of a convex polygon.

It can be proved that the output satisfying the above constraints is unique.

힌트

The following illustrates the initial magic\color{red}{\text{m}} \color{brown}{\text{a}} \color{orange}{\text{g}} \color{blue}{\text{i}} \color{magenta} {\text{c}} circle for the first sample.

The following illustrates the sequence of usage of the tool to make it usable. The dotted part of the boundary is the path modified by the tool, which becomes the red part after the modification.

Step 0Step 1
Step 2Step 3
Step 4