LaLa and Magic Circle (LiLi Version)

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

문제

This is an output-only problem.

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 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, they may lose all their 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 the circle is usable, the tool 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.

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.

Little did LaLa\color{blue}{\text{LaLa}} know, LaLa\color{blue}{\text{LaLa}}'s sister, LiLi\color{purple}{\text{LiLi}}, overheard LaLa\color{blue}{\text{LaLa}}'s plan. Knowing how lazy LaLa\color{blue}{\text{LaLa}} is, as a prank, LiLi\color{purple}{\text{LiLi}} will sneak in a magic\color{red}{\text{m}} \color{brown}{\text{a}} \color{orange}{\text{g}} \color{blue}{\text{i}} \color{magenta} {\text{c}} circle that takes large amount of applications of the tool to make it usable. More specifically, LiLi\color{purple}{\text{LiLi}} will add a magic\color{red}{\text{m}} \color{brown}{\text{a}} \color{orange}{\text{g}} \color{blue}{\text{i}} \color{magenta} {\text{c}} circle to the pile which is a union of equal or less than 1,0001\\,000 line segments and the tool can perform some sequence of modifications with between 120,000120\\,000 and 1,000,0001\\,000\\,000 steps that turns it circle into a usable magic\color{red}{\text{m}} \color{brown}{\text{a}} \color{orange}{\text{g}} \color{blue}{\text{i}} \color{magenta} {\text{c}} circle.

Write a program to help LiLi\color{purple}{\text{LiLi}} compute one such magic circle.

출력

The output should be in the following format:

NN

x_0x\_0 y_0y\_0

x_1x\_1 y_1y\_1

\vdots

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

QQ

a_0a\_0 b_0b\_0 c_0c\_0 d_0d\_0

a_1a\_1 b_1b\_1 c_1c\_1 d_1d\_1

\vdots

a_Q1a\_{Q-1} b_Q1b\_{Q-1} c_Q1c\_{Q-1} d_Q1d\_{Q-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, and it has a sequence of modifications by the tool of length QQ such that ii-th modification choose the counterclockwise path from point (a_i,b_i)(a\_i, b\_i) to (c_i,d_i)(c\_i, d\_i).

The output should satisfy the following constraints:

  • All the numbers in the output are integers.
  • 3N1,0003 \le N \le 1\\,000
  • 120,000Q1,000,000120\\,000 \le Q \le 1\\,000\\,000
  • 0x_i,y_i,a_j,b_j,c_j,d_j1,000,000,0000 \le x\_i, y\_i, a\_j, b\_j, c\_j, d\_j \le 1\\,000\\,000\\,000 for all integers 0i<N0 \le i < N and 0j<Q0 \le j < Q.
  • 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.
  • a_ic_ia\_i \ne c\_i or b_id_ib\_i \ne d\_i for all integers 0i<Q0 \le i < Q.
  • The sequence of points (x_0,y_0),(x_1,y_1),,(x_N1,y_N1)(x\_0, y\_0), (x\_1, y\_1), \cdots, (x\_{N-1}, y\_{N-1}) defines a counterclockwise traversal of the boundary of a simple polygon.
  • Choosing the counterclockwise path from (a_i,b_i)(a\_i, b\_i) to (c_i,d_i)(c\_i, d\_i) for the modification on the magic\color{red}{\text{m}} \color{brown}{\text{a}} \color{orange}{\text{g}} \color{blue}{\text{i}} \color{magenta} {\text{c}} circle after the first ii modifications is valid for all integers 0i<Q0 \le i < Q.
  • 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 usable.

Note that it's allowed to have two consecutive segments meeting at the angle π\pi. Also note that it is not required to minimize any number, your program just have to satisfy all the output constraints.

힌트

Please note that the sample output above does not satisfy the condition 120,000Q1,000,000120\\,000 \le Q \le 1\\,000\\,000, thus it will give Wrong Answer verdict upon submission. It is there only to present the output format.

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 sample output.

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