시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
2 초 | 1024 MB | 5 | 3 | 3 | 100.000% |
$\color{blue}{\text{LaLa}}$ has a pile of $\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 $\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$.
$\color{blue}{\text{LaLa}}$ plans to turn every $\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 $\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, $\color{blue}{\text{LaLa}}$ has the perfect $\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 $\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 $u$ and $v$ such that
And then it rotates the $u$-$v$ path by $\pi$ around the midpoint of $u$ and $v$. In other words, for each point $w$ on the $u$-$v$ path, $w$ becomes $u+v-w$ where the addition is done coordinate-wise over the two dimensional coordinate system over the paper the $\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.
$\color{blue}{\text{LaLa}}$ got annoyed by how long it takes to convert them. In order to finish and take a nap ASAP, $\color{blue}{\text{LaLa}}$ made the following observations.
Therefore, $\color{blue}{\text{LaLa}}$ doesn't have to manually turn $\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, $\color{blue}{\text{LaLa}}$ will compute the usable $\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 $\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 $\color{blue}{\text{LaLa}}$ compute the final $\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:
$N$
$x_0$ $y_0$
$x_0$ $y_0$
$\vdots$
$x_{N-1}$ $y_{N-1}$
where the initial $\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 $N$ line segments connecting points $(x_i, y_i)$ and $(x_{(i+1 \bmod N)}, y_{(i+1 \bmod N)})$ for all integers $0 \le i < N$.
The input satisfies the following constraints:
The output should be in the following format:
$M$
$z_0$ $w_0$
$z_1$ $w_1$
$\vdots$
$z_{M-1}$ $w_{M-1}$
where the final usable $\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 $M$ line segments connecting points $(z_i, w_i)$ and $(z_{(i+1 \bmod M)}, w_{(i+1 \bmod M)})$ for all integers $0 \le i < M$,
The output should satisfy the following constraints:
It can be proved that the output satisfying the above constraints is unique.
8 1 0 4 0 6 0 3 1 5 2 2 1 6 3 0 2
6 0 2 1 0 6 0 12 3 9 4 3 3
The following illustrates the initial $\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 0 | Step 1 |
---|---|
Step 2 | Step 3 |
Step 4 | |
Camp > Osijek Competitive Programming Camp > Winter 2023 > Day 9: Magical Story of LaLa B번