当前位置:网站首页>【luogu P8031】Kućice(计算几何)
【luogu P8031】Kućice(计算几何)
2022-07-30 20:09:00 【SSL_TJH】
Kućice
题目链接:luogu P8031
题目大意
二维平面上有一些点,保证不存在重合的点和散点共线。
求每一个点集的凸包包含的点数的和。
思路
考虑如果每一个凸包都包含了每一个点,那答案是多少: n 2 n n2^{n} n2n
考虑减去不合法的,考虑是怎样的一种情况。
考虑枚举一个点,考虑它不在哪些点集中
不难想象如果你如果弄一个它跟另一个点的线(就是钦定这个点一定要在点集中),那你剩下可以选的点一定就只能在这个线划分成的半平面中的一侧。
那不难想到就是双指针,把其他的点按极角排序,然后用双指针维护固定的一面有多少个。
然后统计一种统计一面,因为另一边到时也会计算到。
然后你再看看如果这一面有 x x x 个点(假设包括上了你那条线上的另一个点),给多少的贡献,那就是 2 x 2^x 2x(因为你只看你一开始枚举的点是否贡献)
然后弄就好了。
代码
#include<cmath>
#include<cstdio>
#include<algorithm>
#define mo 1000000007
#define ll long long
using namespace std;
const int N = 1005;
struct node {
int x, y;
double k;
}a[N], b[N];
node operator +(node x, node y) {
return (node){
x.x + y.x, x.y + y.y, 0.0};}
node operator -(node x, node y) {
return (node){
x.x - y.x, x.y - y.y, 0.0};}
ll operator *(node x, node y) {
return 1ll * x.x * y.y - 1ll * x.y * y.x;}
int n;
ll jc[N], inv[N], invs[N], two[N], ans;
ll C(int n, int m) {
if (m < 0 || m > n) return 0;
return jc[n] * invs[m] % mo * invs[n - m] % mo;
}
ll ksm(ll x, int y) {
ll re = 1;
while (y) {
if (y & 1) re = re * x % mo;
x = x * x % mo; y >>= 1;
}
return re;
}
void Init() {
jc[0] = 1; for (int i = 1; i < N; i++) jc[i] = jc[i - 1] * i % mo;
inv[0] = inv[1] = 1; for (int i = 2; i < N; i++) inv[i] = inv[mo % i] * (mo - mo / i) % mo;
invs[0] = 1; for (int i = 1; i < N; i++) invs[i] = invs[i - 1] * inv[i] % mo;
two[0] = 1; for (int i = 1; i < N; i++) two[i] = two[i - 1] * 2 % mo;
}
bool cmp(node x, node y) {
return x.k < y.k;}
int main() {
freopen("booth.in", "r", stdin);
freopen("booth.out", "w", stdout);
Init();
scanf("%d", &n);
for (int i = 0; i < n; i++) {
scanf("%d %d", &a[i].x, &a[i].y);
}
ans = (two[n] - 1 + mo) % mo * n % mo;
for (int i = 0; i < n; i++) {
int m = 0;
for (int j = 0; j < n; j++) if (j != i)
b[m++] = a[j] - a[i], b[m - 1].k = atan2(b[m - 1].y, b[m - 1].x);
sort(b, b + m, cmp);
int now = 0;
for (int j = 0; j < m; j++) {
while (j != (now + 1) % m && b[j] * b[(now + 1) % m] > 0) now = (now + 1) % m;
(ans += mo - two[(now - j + m) % m] % mo) %= mo;
}
}
printf("%lld", ans);
return 0;
}
边栏推荐
- 倾斜文档扫描与字符识别(opencv,坐标变换分析)
- [NISACTF 2022]下
- These services can't ali interview?Then don't go to, the basic notification, etc
- MySQL夺命10问,你能坚持到第几问?
- [PM only] Quickly count who else in the team has not registered and reported information, and quickly screen out the members of their own project team who have not completed the list of XXX work items
- 普通的int main(){}没有写return 0;会怎么样?
- M3SDA: Moment matching for multi-source domain adaptation
- Brush questions record----string
- Maxwell 一款简单易上手的实时抓取Mysql数据的软件
- WPS表格怎么自动1234排下去?wps表格怎么自动生成序号?
猜你喜欢

推荐系统:开源项目/工具【谷歌:TensorFlow Recommenders】【Facebook:TorchRec】【百度:Graph4Rec】【阿里:DeepRec和EasyRec】

MySQL大总结

推荐系统:实时性【特征实时性:客户端实时特征(秒级,实时)、流处理平台(分钟级,近实时)、分布式批处理平台(小时/天级,非实时)】【模型实时性:在线学习、增量更新、全量更新】

Difference Between Concurrency and Parallelism

Snowflake vs. Redshift的2022战报:两个数据平台谁更适合你?
![KEIL problem: [keil Error: failed to execute 'C:\Keil\ARM\ARMCC']](/img/24/762cec2b4495e80a3e45fac1fac13e.png)
KEIL problem: [keil Error: failed to execute 'C:\Keil\ARM\ARMCC']

Database indexes: indexes are not a panacea

青蛙跳台阶(递归和非递归)-------小乐乐走台阶

Mac安装PHP开发环境

MySQL eight-part text recitation version
随机推荐
Day31 LeetCode
Recommendation System - Sorting Layer: Sorting Layer Architecture [User and Item Feature Processing Steps]
树形结构:二叉树的递归非递归遍历、BST
Snowflake vs. Redshift的2022战报:两个数据平台谁更适合你?
【视频】极值理论EVT与R语言应用:GPD模型火灾损失分布分析
How to build FTP server under win2003
MySQL分组后取最大一条数据【最优解】
MySQL大总结
KEIL问题:【keil Error: failed to execute ‘C:\Keil\ARM\ARMCC‘】
【无标题】多集嵌套集合使不再有MultipleBagFetchException
excel数字如何转换成文本?excel表格数据转换成文本的方法
Swift简介
SQLyog注释 添加 撤销 快捷键
Weak Banks to data conversion ability?Matt software help solve bank dilemma
Zabbix部署与练习
vlookup函数匹配不出来只显示公式的解决方法
To the operation of the int variable assignment is atom?
MySQL大批量造数据
服务器不稳定因素
推荐系统:评估指标【离线评估指标:RMSE(均方根误差)、AUC、准确率、召回率、F1】【在线评估:A/B测试】【一般要求响应时间<0.5s】