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.
输入
The input is given from Standard Input in the following format:
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个点,这些点的子集组成的多边形(内角和<180°)有一个得分,得分为2^(n(多边形上的点+多边形内的点) - |s|(多边形内的点)),求出所有能组成多边形的子集的得分的和。
首先这些能组成多边形的子集为s1+s2+s3+s4.....+sn。
单独对某一个子集来看,这个子集的得分就是:当固定选择多边形上的点时,加上多边形内的点可以组成多少个凸包。
所以总的来看s1+s2+s3+s4......+sn。就相当于给n个点可以形成多少个凸包。
然后就可以用2^n-(不能组成的个数)就是结果。
不能组成凸包的包括
1、空集
2、只有一个的点
3、共线的点
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 998244353;
struct point{
int xx, yy;
}a[205];
ll f[205] = {1ll};
int main(){
int n;
scanf("%d", &n);
for(int i = 0; i < n; i++){
scanf("%d%d", &a[i].xx, &a[i].yy);
f[i + 1] = (f[i] * 2) % mod;
}
ll ans = (f[n] - n - 1 + mod) % mod;//去掉空集和只有一个的点
for(int i = 0; i < n; i++){
for(int j = i + 1; j < n; j++){
int temp = 0;
for(int k = j + 1; k < n; k++){
if((a[i].xx - a[j].xx) * (a[i].yy - a[k].yy) == (a[i].xx - a[k].xx) * (a[i].yy - a[j].yy)){
temp++;
}
}
ans = (ans - f[temp] + mod) % mod;//去掉共线的点
}
}
printf("%lld\n", ans);
return 0;
}