AtCoder Regular Contest 082 E
Problem Statement
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.
Input
The input is given from Standard Input in the following format:
N
x1 y1
x2 y2
:
xN yN
Output
Print the sum of all the scores modulo 998244353.
Sample Input 1
4
0 0
0 1
1 0
1 1
Sample Output 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.
Sample Input 2
5
0 0
0 1
0 2
0 3
1 1
Sample Output 2
11
We have three "triangles" with a score of 1 each, two "triangles" with a score of 2 each, and one "triangle" with a score of 4. Thus, the answer is 11.
Sample Input 3
1
3141 2718
Sample Output 3
0
There are no possible set as S, so the answer is 0.
————————————————————————————————
题意就是求对每个凸多边形,求(2^内部点数)的和 这里我们可以进行一波转换
考虑每个凸多边形,其内部的点每个都可以选择删与不删,得到的方案数就是贡献
而这个转化恰好就等价于不共线的子集数 共线就是子集内所有点在同一直线上
这样之后我们只要用总的子集数减去共线的子集数就好了
枚举直线倾斜角,算包含至少两点的共线子集有几个
倾斜角用枚举两两点得到 然后求gcd使得每个倾角有唯一表达形式
将向量(x,y)转为唯一表示法,然后求个hash
方便sort比较 然后并查集维护 这样复杂度是n^3
当然也可以把斜率离散化从sort换成散列表或者基数排序 然后并查集换成连边,忽略没连到边的点就n^2了
#include<cstdio>
#include<cstring>
#include<algorithm>
const int M=,mod=;
int read(){
int ans=,f=,c=getchar();
while(c<''||c>''){if(c=='-') f=-; c=getchar();}
while(c>=''&&c<=''){ans=ans*+(c-''); c=getchar();}
return ans*f;
}
int n,f[M],sz[M];
int find(int x){while(f[x]!=x) x=f[x]=f[f[x]]; return x;}
int gcd(int x,int y){return y?gcd(y,x%y):x;}
struct pos{int x,y;}q[M];
int cnt;
struct node{
int u,v,w;
bool operator <(const node &x)const{return w<x.w;}
void calc(){
int p=find(u),q=find(v);
if(p!=q) f[q]=p,sz[p]+=sz[q];
}
}e[M*M];
int pw[M],ans;
void prepare(){
pw[]=;
for(int i=;i<=n;i++) pw[i]=(pw[i-]<<)%mod;
}
int main(){
n=read();
prepare(); ans=(pw[n]-n-)%mod;
for(int i=;i<=n;i++) q[i].x=read(),q[i].y=read();
for(int i=;i<=n;i++)
for(int j=;j<i;j++){
int x=q[i].x-q[j].x,y=q[i].y-q[j].y,g=gcd(x,y);
x/=g; y/=g;
if(!x) y=;
if(!y) x=;
if(x<) x=-x,y=-y;
e[++cnt]=(node){i,j,x*+y};
}
std::sort(e+,e++cnt);
for(int i=,j=;i<=cnt;i=j){
for(int k=;k<=n;k++) sz[f[k]=k]=;
while(j<=cnt&&e[j].w==e[i].w) e[j++].calc();
for(int k=;k<=n;k++) if(f[k]==k&&sz[k]>=) ans=(ans-pw[sz[k]]+sz[k]+)%mod;
}printf("%d\n",(ans+mod)%mod);
return ;
}
AtCoder Regular Contest 082 E的更多相关文章
- AtCoder Regular Contest 082 D Derangement
AtCoder Regular Contest 082 D Derangement 与下标相同与下个交换就好了.... Define a sequence of ’o’ and ’x’ of lengt ...
- AtCoder Regular Contest 082
我都出了F了……结果并没有出E……atcoder让我差4分上橙是啥意思啊…… C - Together 题意:把每个数加1或减1或不变求最大众数. #include<cstdio> #in ...
- AtCoder Regular Contest 082 (ARC082) E - ConvexScore 计算几何 计数
原文链接http://www.cnblogs.com/zhouzhendong/p/8934254.html 题目传送门 - ARC082 E 题意 给定二维平面上的$n$个点,定义全集为那$n$个点 ...
- 【推导】【模拟】AtCoder Regular Contest 082 F - Sandglass
题意:有个沙漏,一开始bulb A在上,bulb B在下,A内有a数量的沙子,每一秒会向下掉落1.然后在K个时间点ri,会将沙漏倒置.然后又有m个询问,每次给a一个赋值ai,然后询问你在ti时刻,bu ...
- 【计算几何】【推导】【补集转化】AtCoder Regular Contest 082 E - ConvexScore
题意:平面上给你N个点.对于一个“凸多边形点集”(凸多边形点集被定义为一个其所有点恰好能形成凸多边形的点集)而言,其对答案的贡献是2^(N个点内在该凸多边形点集形成的凸包内的点数 - 该凸多边形点集的 ...
- 【推导】AtCoder Regular Contest 082 D - Derangement
题意:给你一个排列a,每次可以交换相邻的两个数.让你用最少的交换次数使得a[i] != i. 对于两个相邻的a[i]==i的数,那么一次交换必然可以使得它们的a[i]都不等于i. 对于两个相邻的,其中 ...
- AtCoder Regular Contest 082 F
Problem Statement We have a sandglass consisting of two bulbs, bulb A and bulb B. These bulbs contai ...
- AtCoder Regular Contest 082 ABCD
A #include<bits/stdc++.h> using namespace std; ]; int n,m; int main(){ cin>>n>>m; ...
- 【AtCoder Regular Contest 082 F】Sandglass
[链接]点击打开链接 [题意] 你有一个沙漏. 沙漏里面总共有X单位的沙子. 沙漏分A,B上下两个部分. 沙漏从上半部分漏沙子到下半部分. 每个时间单位漏1单位的沙子. 一开始A部分在上面.然后在r1 ...
随机推荐
- 配置ORACLE的PRO*C环境
1.访问数据库的方法 在ORACLE数据库管理和系统中,有三种访问数据库的方法: ⑴.用SQL*Plus, 它有SQL命令以交互的应用程序访问数据库: ⑵.用第四代语言应用开发工具开 ...
- beego orm
http://beego.me/docs/mvc/model/overview.md go get github.com/astaxie/beego/orm Simple Usage package ...
- Python进程、线程、协程及IO多路复用
详情戳击下方链接 Python之进程.线程.协程 python之IO多路复用
- 不同浏览器css引入外部字体的方式
/** * 字体后缀和浏览器有关,如下所示 * .TTF或.OTF,适用于Firefox 3.5.Safari.Opera * .EOT,适用于Internet Explorer 4.0+ * .SV ...
- fidder工具学习抓取Firefox包
fidder抓取Firefox的https请求 抓包之前需要设置fidder,我下面的截图是fidder4,打开fidder—>Tools—>Options如图: 选择https,勾选所有 ...
- C 计算金额
#include <stdio.h> int main(int argc, char **argv) { \\定义两个变量 a金额 z跟票面 int a=0; int z=0;\\ 输入金 ...
- Python 3 学习笔记之——面向对象
1. 类的介绍 类(Class) 用来描述具有相同的属性和方法的对象的集合.它定义了该集合中每个对象所共有的属性和方法.对象是类的实例,类是对象的抽象. 方法:类中定义的函数. 类变量:类变量在整个实 ...
- eclipse 创建Makefile工程生成多个执行文件
1.创建Makefile工程 2.创建inc src Debug 目录 用于存放头文件源文件 3.编写Makefile 需要在有源文件的目标天剑Makefile文件,如下给出一个生成两个target的 ...
- Luogu2570 ZJOI2010 贪吃的老鼠 二分答案+最大流
题目链接:https://www.luogu.org/problemnew/show/P2570 题意概述: 好像没什么好概述的.....很简洁? 分析: 首先想到二分时间,转化成判定性问题,在一定时 ...
- 第十三次ScrumMeeting会议
第十三次Scrum Meeting 时间:2017/12/1 地点:咖啡馆 人员:策划组美工组 名字 完成的工作 计划工作 蔡帜 完成公式的基本策划,Bug数量产生机制设计 科技树方面机制确定 游心 ...