6603: ConvexScore
时间限制: 1 Sec 内存限制: 128 MB提交: 61 解决: 27
[提交] [状态] [讨论版] [命题人:admin]
题目描述
You are given N points (xi,yi) located on a two-dimensional plane. Consider a subset S of the N points that forms a convex polygon. Here, we say a set of points S forms a convex polygon when there exists a convex polygon with a positive area that has the same set of vertices as S. All the interior angles of the polygon must be strictly less than 180°.
For example, in the figure above, {A,C,E} and {B,D,E} form convex polygons; {A,C,D,E}, {A,B,C,E}, {A,B,C}, {D,E} and {} do not.
For a given set S, let n be the number of the points among the N points that are inside the convex hull of S (including the boundary and vertices). Then, we will define the score of S as 2n−|S|.
Compute the scores of all possible sets S that form convex polygons, and find the sum of all those scores.
However, since the sum can be extremely large, print the sum modulo 998244353.
Constraints
1≤N≤200
0≤xi,yi<104(1≤i≤N)
If i≠j, xi≠xj or yi≠yj.
xi and yi are integers.

For a given set S, let n be the number of the points among the N points that are inside the convex hull of S (including the boundary and vertices). Then, we will define the score of S as 2n−|S|.
Compute the scores of all possible sets S that form convex polygons, and find the sum of all those scores.
However, since the sum can be extremely large, print the sum modulo 998244353.
Constraints
1≤N≤200
0≤xi,yi<104(1≤i≤N)
If i≠j, xi≠xj or yi≠yj.
xi and yi are integers.
输入
The input is given from Standard Input in the following format:
N
x1 y1
x2 y2
:
xN yN
N
x1 y1
x2 y2
:
xN yN
输出
Print the sum of all the scores modulo 998244353.
样例输入
4
0 0
0 1
1 0
1 1
样例输出
5
提示
We have five possible sets as S, four sets that form triangles and one set that forms a square. Each of them has a score of 20=1, so the answer is 5.
来源/分类
思路:
在平面直角坐标系中有一个n元点集U={Ai(xi,yi)|1≤i≤n}。考虑以U的子集S中的点为顶点围成的凸多边形P,若这个凸多边形P内(含边界)的点数为k,则这个子集S的权值为f(S)=2k-|S|。求所有子集S的权值之和(对998,244,353取余)。
定义一个点集上的凸包运算H:G→S。即:平面上的一个点集G,有凸包S=H(G)。
设凸多边形P内的点(除顶点外)构成的集合为T,则|T|=k-|S|。于是,f(S)=2|T|,即f(S)为T的子集个数。设T’是T的一个子集,则:由于集合S=H(S∪T’),即S为S∪T’的凸包,故集合S∪T’对f(S)的贡献为1。
于是,对于U的一个子集G,若凸多边形P的顶点集为H(G),则集合G对ans的贡献为1。实际上,就是求总集合有多少子集能构成凸多边形!
AC代码:
#include <bits/stdc++.h> using namespace std; const int mod=998244353; int x[210],y[210],p[210],n,cnt,ans; int main() { scanf("%d",&n); for (int i=0;i<n;i++) { scanf("%d %d",&x[i],&y[i]); } p[0]=1; for(int i=0;i<n;i++) { p[i+1]=(p[i]<<1)%mod; } ans=p[n]-n-1;//要组成凸包,所有情况减去取一个点的情况和减去都不取的情况 for(int i=0;i<n;i++) //固定两个点,枚举其他点 { for(int j=0;j<i;j++) { cnt=0; for(int k=0;k<j;k++) { if((x[i]-x[j])*(y[i]-y[k])==(x[i]-x[k])*(y[i]-y[j]))//斜率相等,共线 { cnt++; } } ans=(ans-p[cnt]+mod)%mod; } } printf("%d ",ans); return 0; }