Codeforces Global Round 7
G
Spiderweb Trees
Codeforces
3500
原题
← F2→
翻译中…

Let's call a graph with $n$ vertices, each of which has it's own point $A_i = (x_i, y_i)$ with integer coordinates, a planar tree if:

翻译中…
  • All points $A_1, A_2, \ldots, A_n$ are different and no three points lie on the same line.
  • The graph is a tree, i.e. there are exactly $n-1$ edges there exists a path between any pair of vertices.
  • For all pairs of edges $(s_1, f_1)$ and $(s_2, f_2)$, such that $s_1 \neq s_2, s_1 \neq f_2,$ $f_1 \neq s_2$, and $f_1 \neq f_2$, the segments $A_{s_1} A_{f_1}$ and $A_{s_2} A_{f_2}$ don't intersect.
翻译中…

Imagine a planar tree with $n$ vertices. Consider the convex hull of points $A_1, A_2, \ldots, A_n$. Let's call this tree a spiderweb tree if for all $1 \leq i \leq n$ the following statements are true:

翻译中…
  • All leaves (vertices with degree $\leq 1$) of the tree lie on the border of the convex hull.
  • All vertices on the border of the convex hull are leaves.
翻译中…

An example of a spiderweb tree:

翻译中…

image

翻译中…

The points $A_3, A_6, A_7, A_4$ lie on the convex hull and the leaf vertices of the tree are $3, 6, 7, 4$.

翻译中…

Refer to the notes for more examples.

翻译中…

Let's call the subset $S \subset \{1, 2, \ldots, n\}$ of vertices a subtree of the tree if for all pairs of vertices in $S$, there exists a path that contains only vertices from $S$. Note that any subtree of the planar tree is a planar tree.

翻译中…

You are given a planar tree with $n$ vertexes. Let's call a partition of the set $\{1, 2, \ldots, n\}$ into non-empty subsets $A_1, A_2, \ldots, A_k$ (i.e. $A_i \cap A_j = \emptyset$ for all $1 \leq i \lt j \leq k$ and $A_1 \cup A_2 \cup \ldots \cup A_k = \{1, 2, \ldots, n\}$) good if for all $1 \leq i \leq k$, the subtree $A_i$ is a spiderweb tree. Two partitions are different if there exists some set that lies in one parition, but not the other.

翻译中…

Find the number of good partitions. Since this number can be very large, find it modulo $998\,244\,353$.

翻译中…

Input

翻译中…

The first line contains an integer $n$ ($1 \leq n \leq 100$) — the number of vertices in the tree.

翻译中…

The next $n$ lines each contain two integers $x_i, y_i$ ($-10^9 \leq x_i, y_i \leq 10^9$)  — the coordinates of $i$-th vertex, $A_i$.

翻译中…

The next $n-1$ lines contain two integers $s, f$ ($1 \leq s, f \leq n$) — the edges $(s, f)$ of the tree.

翻译中…

It is guaranteed that all given points are different and that no three of them lie at the same line. Additionally, it is guaranteed that the given edges and coordinates of the points describe a planar tree.

翻译中…

Output

翻译中…

Print one integer  — the number of good partitions of vertices of the given planar tree, modulo $998\,244\,353$.

翻译中…

Note

翻译中…

image The picture for the first sample.

翻译中…

In the first test case, all good partitions are:

翻译中…
  1. $\{1\}$, $\{2\}$, $\{3\}$, $\{4\}$;
  2. $\{1, 2\}$, $\{3\}$, $\{4\}$;
  3. $\{1, 3\}$, $\{2\}$, $\{4\}$;
  4. $\{1, 4\}$, $\{2\}$, $\{3\}$;
  5. $\{1, 2, 3, 4\}$.
翻译中…

The partition $\{1, 2, 3\}$, $\{4\}$ isn't good, because the subtree $\{1, 2, 3\}$ isn't spiderweb tree, since the non-leaf vertex $1$ lies on the convex hull.

翻译中…

The partition $\{2, 3, 4\}$, $\{1\}$ isn't good, because the subset $\{2, 3, 4\}$ isn't a subtree.

翻译中…

image The picture for the second sample.

翻译中…

In the second test case, the given tree isn't a spiderweb tree, because the leaf vertex $1$ doesn't lie on the convex hull. However, the subtree $\{2, 3, 4, 5\}$ is a spiderweb tree.

翻译中…

image The picture for the third sample.

翻译中…

image The picture for the fourth sample.

翻译中…

In the fourth test case, the partition $\{1, 2, 3, 4\}$, $\{5, 6, 7, 8\}$ is good because all subsets are spiderweb subtrees.

翻译中…

样例

Input #1
4
0 0
0 1
-1 -1
1 -1
1 2
1 3
1 4
Output #1
5
InputCopy OutputCopy
Input #2
5
3 2
0 -3
-5 -3
5 -5
4 5
4 2
4 1
5 2
2 3
Output #2
8
InputCopy OutputCopy
Input #3
6
4 -5
0 1
-2 8
3 -10
0 -1
-4 -5
2 5
3 2
1 2
4 6
4 2
Output #3
13
InputCopy OutputCopy
Input #4
8
0 0
-1 2
-2 5
-5 1
1 3
0 3
2 4
-1 -4
1 2
3 2
5 6
4 2
1 5
5 7
5 8
Output #4
36
InputCopy OutputCopy
题目信息
题号
1326G
时间限制
1 s
内存限制
256 MB
标签
动态规划
计算几何
树

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