CF1326G.Spiderweb Trees
NOI/NOI+/CTSC
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Let's call a graph with n vertices, each of which has it's own point Ai=(xi,yi) with integer coordinates, a planar tree if:
- All points A1,A2,…,An 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 (s1,f1) and (s2,f2), such that s1=s2,s1=f2, f1=s2, and f1=f2, the segments As1Af1 and As2Af2 don't intersect.
Imagine a planar tree with n vertices. Consider the convex hull of points A1,A2,…,An. Let's call this tree a spiderweb tree if for all 1≤i≤n the following statements are true:
- All leaves (vertices with degree ≤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:

The points A3,A6,A7,A4 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⊂1,2,…,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,…,n into non-empty subsets A1,A2,…,Ak (i.e. Ai∩Aj=∅ for all 1≤i<j≤k and A1∪A2∪…∪Ak=1,2,…,n) good if for all 1≤i≤k, the subtree Ai 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 998244353.
我们称一个具有 n 个顶点的图(每个顶点 Ai=(xi,yi) 具有整数坐标)为平面树,若满足以下条件:
- 所有点 A1,A2,…,An 互不相同,且任意三点不共线;
- 该图是一棵树,即恰好有 n−1 条边,且任意两个顶点之间均存在一条路径;
- 对于任意两条边 (s1,f1) 和 (s2,f2),若满足 s1=s2、s1=f2、f1=s2 且 f1=f2,则线段 As1Af1 与 As2Af2 不相交。
考虑一个含 n 个顶点的平面树。设 A1,A2,…,An 的凸包为该点集的凸包。若对所有 1≤i≤n,以下两个条件均成立,则称该树为蛛网树(spiderweb tree):
- 树的所有叶子(度数 ≤1 的顶点)均位于凸包的边界上;
- 凸包边界上的所有顶点均为叶子。
一个蛛网树示例:

其中点 A3,A6,A7,A4 位于凸包上,而该树的叶子顶点为 3,6,7,4。
更多示例请参见题目附注。
我们称顶点集合 S⊂{1,2,…,n} 为该树的一个子树,当且仅当对 S 中任意两个顶点,均存在一条仅由 S 中顶点构成的路径。注意:平面树的任意子树本身也是平面树。
现给定一个含 n 个顶点的平面树。将集合 {1,2,…,n} 划分为若干非空子集 A1,A2,…,Ak(即对所有 1≤i<j≤k,有 Ai∩Aj=∅,且 A1∪A2∪…∪Ak={1,2,…,n}),若对每个 1≤i≤k,子树 Ai 均为蛛网树,则称该划分为好划分(good partition)。若存在某个子集属于一个划分但不属于另一个划分,则称这两个划分不同。
求好划分的总数。由于该数可能极大,请输出其对 998244353 取模的结果。
输入格式
The first line contains an integer n (1≤n≤100) — the number of vertices in the tree.
The next n lines each contain two integers xi,yi (−109≤xi,yi≤109) — the coordinates of i-th vertex, Ai.
The next n−1 lines contain two integers s,f (1≤s,f≤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.
第一行包含一个整数 n(1≤n≤100)——树中顶点的数量。
接下来的 n 行,每行包含两个整数 xi,yi(−109≤xi,yi≤109)——第 i 个顶点 Ai 的坐标。
接下来的 n−1 行,每行包含两个整数 s,f(1≤s,f≤n)——树的边 (s,f)。
保证所有给定的点互不相同,且其中任意三点不共线。此外,保证所给的边和点的坐标描述了一棵平面树。
输出格式
Print one integer — the number of good partitions of vertices of the given planar tree, modulo 998244353.
输出一个整数——给定平面树的顶点的“好划分”数量,对 998244353 取模。
输入输出样例
输入#1
4 0 0 0 1 -1 -1 1 -1 1 2 1 3 1 4
输出#1
5
输入#2
5 3 2 0 -3 -5 -3 5 -5 4 5 4 2 4 1 5 2 2 3
输出#2
8
输入#3
6 4 -5 0 1 -2 8 3 -10 0 -1 -4 -5 2 5 3 2 1 2 4 6 4 2
输出#3
13
输入#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
输出#4
36
说明/提示
The picture for the first sample.
In the first test case, all good partitions are:
- 1, 2, 3, 4;
- 1,2, 3, 4;
- 1,3, 2, 4;
- 1,4, 2, 3;
- 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.
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.
The picture for the third sample.
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.
第一个样例的示意图。
在第一个测试用例中,所有合法的划分如下:
- 1, 2, 3, 4;
- 1,2, 3, 4;
- 1,3, 2, 4;
- 1,4, 2, 3;
- 1,2,3,4。
划分 1,2,3, 4 不合法,因为子树 1,2,3 不是蛛网树(spiderweb tree),原因是其非叶节点 1 位于凸包上。
划分 2,3,4, 1 不合法,因为子集 2,3,4 并非一棵子树。
第二个样例的示意图。
在第二个测试用例中,给定的树本身不是蛛网树,因为叶节点 1 不在凸包上。然而,子树 2,3,4,5 是蛛网树。
第三个样例的示意图。
第四个样例的示意图。
在第四个测试用例中,划分 1,2,3,4, 5,6,7,8 是合法的,因为其中每个子集均为蛛网子树。
输入解题思路,AI测评打分。不知道怎么写?