给出点集,然后求一个凸包的所有的子凸包的贡献总和,贡献计算是凸包内部含边界上点的数量N,凸包的不包含边界的顶点数S,贡献为$2^{N-S}$

首先很容易想到,凸包上包含内部的所有点构成的子凸包有Sum(i = 3 ->N)C(i,N)种情况,这个式子其实就是二项式的一部分。但是有可能出现多点共线的不合法情况,所以问题转换为求所有点构成的直线中,每条直线上大于2点的点的数目,每条直线都要分别计算,最后减去就行了。求共线可以用叉积可以用斜率,注意判重。

这场比赛迟了10分钟才写,这题开始还在用凸包搞,简直蠢(

/** @Date    : 2017-09-02 20:30:47
* @FileName: C.cpp
* @Platform: Windows
* @Author : Lweleth (SoungEarlf@gmail.com)
* @Link : https://github.com/
* @Version : $Id$
*/
#include <bits/stdc++.h>
#define LL long long
#define PII pair<int ,int>
#define MP(x, y) make_pair((x),(y))
#define fi first
#define se second
#define PB(x) push_back((x))
#define MMG(x) memset((x), -1,sizeof(x))
#define MMF(x) memset((x),0,sizeof(x))
#define MMI(x) memset((x), INF, sizeof(x))
using namespace std; const int INF = 0x3f3f3f3f;
const int N = 210;
const double eps = 1e-6;
const LL mod = 998244353; LL fa[210], inv[210]; LL fpow(LL a, LL n)
{
LL r = 1LL;
while(n > 0)
{
if(n & 1)
r = r * a % mod;
a = a * a % mod;
n >>= 1;
}
return r;
} void init()
{
fa[0] = 1;
inv[0] = 1;
for(LL i = 1; i <= 200; i++)
{
fa[i] = fa[i-1] * i % mod;
inv[i] = fpow(fa[i], mod - 2);
}
} LL C(LL n, LL m)
{
if(n < 0)
return 0;
n >>= 1;
if(n == 0)
return 1LL;
LL ans = 0;
ans = ((fa[n + m] * inv[m] % mod)* inv[n]) % mod;
return ans;
} struct point
{
double x, y;
point(){}
point(double _x, double _y){x = _x, y = _y;}
point operator -(const point &b) const
{
return point(x - b.x, y - b.y);
}
double operator *(const point &b) const
{
return x * b.x + y * b.y;
}
double operator ^(const point &b) const
{
return x * b.y - y * b.x;
}
bool operator == (const point &b) const
{
return x==b.x && y==b.y;
} }; double xmult(point p1, point p2, point p0)
{
return (p1 - p0) ^ (p2 - p0);
} double distc(point a, point b)
{
return sqrt((double)((b - a) * (b - a)));
}
int sign(double x)
{
if(fabs(x) < eps)
return 0;
if(x < 0)
return -1;
else
return 1;
} struct line
{
point s, t;
line(){}
line(point ss, point tt){
s = ss, t = tt;
}
}; ////////
int n;
point stk[N];
point p[N]; int cmpC(point a, point b)//水平序排序
{
return sign(a.x - b.x) < 0 || (sign(a.x - b.x) == 0 && sign(a.y - b.y) < 0);
} int Graham()//水平序
{
sort(p, p + n, cmpC);
int top = 0;
for(int i = 0; i < n; i++)
{
while(top >= 2 && sign(xmult(stk[top - 2], stk[top - 1], p[i])) < 0)
top--;
stk[top++] = p[i];
}
int tmp = top;
for(int i = n - 2; i >= 0; i--)
{
while(top > tmp && sign(xmult(stk[top - 2],stk[top - 1] ,p[i] )) < 0)
top--;
stk[top++] = p[i];
}
if(n > 1)
top--;
return top;
} LL check(int m)
{
//cout << m << endl;
LL c = 2;
LL t = 0;
for(int i = 1; i < m; i++)
{
if(sign(xmult(stk[i - 1], stk[(i + 1)%(m)], stk[i])) == 0)
c++;
else t = (t + fpow(2, c) - (1LL + c + c * (c - 1) / 2LL) + mod) % mod, c = 2;
//cout << c << endl;
}
if(c > 2)
t = (t + fpow(2, c) - (1LL + c + c * (c - 1) / 2LL) + mod) % mod;
return t;
} /////////
int main()
{ while(~scanf("%d", &n))
{
for(int i = 0; i < n; i++)
{
double x, y;
scanf("%lf%lf", &x, &y);
p[i] = point(x, y);
}
LL ans = 0;
LL cnt = Graham();
//cout << cnt;
//ans = (fpow(2, n) - check(cnt) - (1LL + n + (n - 1) * n / 2LL) + mod) % mod;
ans = (fpow(2, n) - (1LL + n) + mod) % mod;
for(int i = 0; i < n; i++)
{
map<LL, int>q;
for(int j = i + 1; j < n; j++)
{
LL t;
if(p[i].x == p[j].x)
t = -1;
else t = ((LL)(p[j].y - p[i].y) * fpow(p[j].x - p[i].x, mod - 2) % mod + mod ) % mod;
q[t]++;
}
for(auto j : q)
{
ans -= fpow(2, j.se) - 1;
ans %= mod;
}
}
while(ans < 0)
ans += mod;
if(cnt > 2)
printf("%lld\n", ans);
else printf("0\n");
}
return 0;
}

atcoder #082 E 暴力 计算几何的更多相关文章

  1. Atcoder Regular 099 暴力区间扩张 n/dig(n)极值打表 团分割背包

    C 直接把第一次加在哪里for一遍即可 /*Huyyt*/ #include<bits/stdc++.h> #define mem(a,b) memset(a,b,sizeof(a)) u ...

  2. 【HDOJ】5128

    暴力+计算几何. /* 5128 */ #include <iostream> #include <algorithm> #include <cstdio> #in ...

  3. 2018acm-icpc西安邀请赛后记

    第一次参加icpc的邀请赛,有一点小激动,深知大一弱队实力弱,赛前给队友的目标就是拿块铜,不打铁. 热身赛因为没有用过pc^2,codeblocks又用不习惯的原因,开始调工程调了很久,差一点拿到A题 ...

  4. uva 12296 Pieces and Discs (Geometry)

    http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&p ...

  5. AtCoder Regular Contest 082 (ARC082) E - ConvexScore 计算几何 计数

    原文链接http://www.cnblogs.com/zhouzhendong/p/8934254.html 题目传送门 - ARC082 E 题意 给定二维平面上的$n$个点,定义全集为那$n$个点 ...

  6. 【计算几何】【推导】【补集转化】AtCoder Regular Contest 082 E - ConvexScore

    题意:平面上给你N个点.对于一个“凸多边形点集”(凸多边形点集被定义为一个其所有点恰好能形成凸多边形的点集)而言,其对答案的贡献是2^(N个点内在该凸多边形点集形成的凸包内的点数 - 该凸多边形点集的 ...

  7. 汕头市队赛 SRM14 T1 计算几何瞎暴力

    计算几何瞎暴力 (easy.pas/c/cpp) 128MB 1s 在平面上,给定起点和终点,有一面墙(看作线段)不能穿过,问从起点走到终点的最短路程. 输入格式 输入一行,包含8个用空格分隔的整数x ...

  8. LibreOJ #517. 「LibreOJ β Round #2」计算几何瞎暴力

    二次联通门 : LibreOJ #517. 「LibreOJ β Round #2」计算几何瞎暴力 /* LibreOJ #517. 「LibreOJ β Round #2」计算几何瞎暴力 叫做计算几 ...

  9. HDU 6697 Closest Pair of Segments (计算几何 暴力)

    2019 杭电多校 10 1007 题目链接:HDU 6697 比赛链接:2019 Multi-University Training Contest 10 Problem Description T ...

随机推荐

  1. 不要USB数据线调试Android开发

    不管是过去Eclipse还是现在的Android Studio开发Android,运行或者调试时都会利用USB数据线连接电脑和手机,特别是当现在的手机只有一个Type-c接口,意味着,插上后,啥也干不 ...

  2. lintcode-411-格雷编码

    411-格雷编码 格雷编码是一个二进制数字系统,在该系统中,两个连续的数值仅有一个二进制的差异. 给定一个非负整数 n ,表示该代码中所有二进制的总数,请找出其格雷编码顺序.一个格雷编码顺序必须以 0 ...

  3. 【C】多线程编程笔记

    1. pthread_create(pthread类型指针变量 ,NULL ,函数 ,函数参数[多个参数用结构体传]) 2. pthread_join(pthread类型指针变量, 返回一般为null ...

  4. TP中if标签

    if标签 If标签如果php中if语句的作用,if是用于流程控制的. 在ThinkPHP中if标签也是用于流程控制的. If标签的语法格式: <if condition=’条件表达式’> ...

  5. display:table的几个妙用:垂直居中、浮动……

    一.为什么不用table系表格元素? 目前,在大多数开发环境中,已经基本不用table元素来做网页布局了,取而代之的是div+css,那么为什么不用table系表格元素呢? 1.用DIV+CSS编写出 ...

  6. bzoj4770 图样

    题意 n个点的完全图,每个点的点权是在m位的二进制数中随机选取的.每条边的边权是两个点的点权的异或值. 问最小生成树的边权和的期望.模一个质数输出. 分析 考试的时候写这个题,然后期望得分100-&g ...

  7. java垃圾回收 - 为什么要进行垃圾回收

    1.为什么要进行垃圾回收:      在C++中,对象所占的内存在程序结束运行之前一直被占用,在明确释放之前不能分配给其它对象:而在Java中,当没有对象引用指向原先分配给某个对象 的内存时,该内存便 ...

  8. Docker学习笔记三:Docker部署Java web系统

    Docker部署Java Web系统 1.在root目录下创建一个路径test/app mkdir test && cd test&& mkdir app && ...

  9. BZOJ1187:[HNOI2007]神奇游乐园——题解

    http://www.lydsy.com/JudgeOnline/problem.php?id=1187 Description 经历了一段艰辛的旅程后,主人公小P乘坐飞艇返回.在返回的途中,小P发现 ...

  10. 洛谷 P3539 [POI2012]ROZ-Fibonacci Representation 解题报告

    P3539 [POI2012]ROZ-Fibonacci Representation 题意:给一个数,问最少可以用几个斐波那契数加加减减凑出来 多组数据10 数据范围1e17 第一次瞬间yy出做法, ...