AtCoder Regular Contest 082E ConvexScore 乱搞

38 篇文章 0 订阅
36 篇文章 0 订阅

Description


给n个平面上的点。定义一个点的集合S的权值为2|S|-|T|,其中T是集合S在凸包上的点
求所有点的集合的权值之和

Solution


看不懂题是最大的阻碍。。

那个|S|-|T|实际上就是凸包内部的点,那么S权值的含义就是那些点集的凸包和S的凸包相同
于是问题就变成了可以任意选点,问组成凸包的数量。这个我们减去单点和直线的情况算答案就可以了

Code


#include <stdio.h>
#include <string.h>
#include <algorithm>
#define rep(i,st,ed) for (int i=st;i<=ed;++i)

typedef long long LL;
const int MOD=998244353;
const int N=200005;

struct pos {int x,y;} p[N];

pos operator -(pos a,pos b) {
	return (pos) {a.x-b.x,a.y-b.y};
}

int operator *(pos a,pos b) {
	return a.x*b.y-b.x*a.y;
}

LL bin[N];

int read() {
	int x=0,v=1; char ch=getchar();
	for (;ch<'0'||ch>'9';v=(ch=='-')?(-1):v,ch=getchar());
	for (;ch<='9'&&ch>='0';x=x*10+ch-'0',ch=getchar());
	return x*v;
}

bool line(pos a,pos b,pos c) {
	return (a-b)*(c-b)==0;
}

int main(void) {
	bin[0]=1; rep(i,1,N-1) bin[i]=bin[i-1]*2LL%MOD;
	int n=read();
	rep(i,1,n) p[i].x=read(),p[i].y=read();
	LL ans=bin[n]-n-1-(n-1)*n/2; ans=(ans%MOD+MOD)%MOD;
	rep(i,1,n) rep(j,i+1,n) {
		int s=0;
		rep(k,j+1,n) {
			s+=line(p[i],p[j],p[k]);
		}
		ans=(ans+MOD-bin[s]+1)%MOD;
	}
	printf("%lld\n", ans);
	return 0;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值