Order Capital Round 1 (Codeforces Round 1038, Div. 1 + Div. 2)
F
Colorful Polygon
Codeforces
3400
原题
← EG →
翻译中…

You are given an array $a_1, a_2, \ldots, a_n$, where $n \leq 8$ and $a_1 + a_2 + \cdots + a_n \leq 100$.

翻译中…

Construct a simple polygon$^{\text{∗}}$ with at most $333$ vertices that has exactly $$\frac{(a_1 + a_2 + \cdots + a_n)!}{a_1! a_2! \cdots a_n!}$$ different triangulations$^{\text{†}}$. It can be proven that such a polygon always exists.

翻译中…

$^{\text{∗}}$A simple polygon is a polygon that does not intersect itself and has no holes. In other words, no two non-consecutive edges can have common points, and consecutive edges must have exactly one common point — the vertex between them. Consecutive edges may be collinear.$^{\text{†}}$A triangulation of a polygon with $m$ vertices is a set of $m-3$ diagonals that intersect only at vertices. A diagonal is a segment between two vertices which lies inside the polygon and has exactly two common points with the polygon sides — the vertices it connects.

翻译中…

Input

翻译中…

The first line of each test contains a single integer $n$ ($2 \leq n \leq 8$) — the number of elements in the array.

翻译中…

The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \leq a_i \leq 100$) — the elements of the array.

翻译中…

It is guaranteed that $a_1 + a_2 + \cdots + a_n$ does not exceed $100$.

翻译中…

Output

翻译中…

In the first line, output a single integer $m$ ($3 \leq m \leq 333$) — the number of vertices in the polygon.

翻译中…

In the $i$-th of the following $m$ lines, output two integers $x_i$, $y_i$ ($-10^6 \leq x_i, y_i \leq 10^6$) — the coordinates of the $i$-th vertex of the polygon.

翻译中…

The polygon must be simple. The vertices may be given in either clockwise or counterclockwise order.

翻译中…

Note

翻译中…

In the first test, the required polygon has to have $\tfrac{4!}{1! 1! 2!} = 12$ triangulations. The following are all the triangulations of the example polygon.

翻译中…

image

翻译中…

In the second test, the required polygon has to have $\tfrac{5!}{4! 1!} = 5$ triangulations.

翻译中…

image

翻译中…

样例

Input #1
3
1 1 2
Output #1
8
0 0
2 1
4 2
6 1
3 5
4 7
0 5
1 2
InputCopy OutputCopy
Input #2
2
4 1
Output #2
5
-2 -2
-3 1
0 3
3 1
2 -2
InputCopy OutputCopy
题目信息
题号
2122F
时间限制
2 s
内存限制
256 MB
标签
构造
分治
计算几何

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。