ConvexScore(ABC072&ARC082)
ConvexScore
时间限制: 1 Sec 内存限制: 128 MB题目描述
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 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.
输入
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 个点,对于一个凸 n 边形,称其的 n 个顶点构成一个集合 S,并且这个多边形内及其边上有 k 个顶点,定义这个 S 的 score为 2^(k-n)
对所有的 score 求和,输出 mod 998244353 的值。
题解:可以转化为固定某个凸包,在里面或边上添加或不添加点的方案数
即所有的可能 - 只有一个点 - 空集 - 共线的情况
共线的情况 可以枚举 确定某两点,枚举第三个点(0(n**3)),共线用向量的点乘判断
c++ code:
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int N = 2000+10; const int mod = 998244353; int x[N],y[N]; ll f[N]; int cal(int i ,int j,int k) { return (x[j] - x[i])*(y[k] - y[j]) == (y[j] - y[i])*(x[k] - x[j]); } int main() { for(int i = 0;i < N;i++) f[i] = i == 0?1:(f[i-1]<<1)%mod; int n; scanf("%d",&n); for(int i = 1;i <= n ;i++) scanf("%d%d",&x[i],&y[i]); ll ans = f[n] - n - 1; for(int i = 1;i <= n;i++) for(int j = i+1;j <= n;j++) { int tot = 0; for(int k = j+1;k <= n;k++) if(cal(i,j,k)) tot++; // 共线 ans = (ans - f[tot] + mod )%mod; } printf("%lld\n",ans); return 0; }