upc 6603 ConvexScore

本文探讨了一种算法,用于计算平面上N个点的所有可能凸多边形的分数总和,分数定义为2的幂次方乘以内含点数量减去顶点数量。通过排除直线、单点和空集等非凸多边形情况,实现暴力枚举所有可能的凸多边形。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

                                                 6603: 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.

 

输入

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个点的坐标, 求n个点的所有子集中能围成的凸多边形的贡献值的和,每个凸多边形的贡献值是 2^(凸多边形内包含的点的个数, 不包括边界)。

 

 

 

 

分析:

经过观察我们可以发现,每个凸多边形的贡献值,就是固定选构成凸多边形的点, 然后任意选凸多边形内的点,所构成的多边形(不存在凸多边形,这个很容易发现)的个数。 所以最终我们就只求一下这n个点一共能够构成多少个多边形就ok了。 暴力枚举就行了,用总的情况 - 不能构成多边行的情况(直线、单个点、空集)

 

 

 

 

 

AC代码:

 /*************************************************
       Author       :	NIYOUDUOGAO
       Last modified:	2018-07-31 09:07
       Email        :	pjm000@163.com
       Filename     :	t1.cpp
 *************************************************/
#include <bits/stdc++.h>
#define mset(a, x) memset(a, x, sizeof(a))
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const int mod = 998244353;
const int N = 1e5 + 5;
ll p[205];
struct node {
	int x, y;
}a[205];
int main() {
    std::ios::sync_with_stdio(false);
    cin.tie(NULL), cout.tie(NULL);
	p[0] = 1;
	for (int i = 1; i <= 200; i++) {
		p[i] = (p[i - 1] << 1) % mod;
	}
   	int n;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i].x >> a[i].y;
	}
	ll res = (p[n] - n - 1 + mod) % mod;
	for (int i = 1; i <= n; i++) {
		for (int j = i + 1; j <= n; j++) {
			int cnt = 0;
			for (int k = j + 1; k <= n; k++) {
				if ((a[i].x - a[j].x) * (a[i].y - a[k].y) == (a[i].x - a[k].x) * (a[i].y - a[j].y)) {
					cnt++;
				}
			}
			res = (res - p[cnt] + mod) % mod;
		}
	}
	cout << res << endl;
    return 0;
}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值