当前位置:网站首页>【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;
}
边栏推荐
- excel数字下拉递增怎么设置?
- Cesium loads offline maps and offline terrain
- MySQL数据库之JDBC编程
- HMS Core Discovery第16期回顾|与虎墩一起,玩转AI新“声”态
- 推荐系统-排序层:排序层架构【用户、物品特征处理步骤】
- mysql8 installation under linux
- 推荐系统:实时性【特征实时性:客户端实时特征(秒级,实时)、流处理平台(分钟级,近实时)、分布式批处理平台(小时/天级,非实时)】【模型实时性:在线学习、增量更新、全量更新】
- el-input can only input integers (including positive numbers, negative numbers, 0) or only integers (including positive numbers, negative numbers, 0) and decimals
- 使用MULTISET来比较数据集的实例介绍
- mysql慢查询优化
猜你喜欢

Install MySQL tutorial under Linux

从离线到实时对客,湖仓一体释放全量数据价值

MySQL分库分表

推荐系统:概述【架构:用户/物品特征工程---->召回层---->排序层---->测试/评估】【冷启动问题、实时性问题】

网络层协议------IP协议

MySQL six-pulse sword, SQL customs clearance summary

Install Mysql5.7 under Linux, super detailed and complete tutorial, and cloud mysql connection

PPT如何开启演讲者模式?PPT开启演讲者模式的方法

Linux下最新版MySQL 8.0的下载与安装(详细步骤)

365天挑战LeetCode1000题——Day 044 按公因数计算最大组件大小 并查集
随机推荐
TensorFlow2: Overview
Linux下安装MySQL教程
MySQL mass production of data
历史上的今天:Win10 七周年;微软和雅虎的搜索协议;微软发行 NT 4.0
如何优化OpenSumi终端性能?
服务器不稳定因素
vookloop函数怎么用?vlookup函数的使用方法介绍
如何解决gedit 深色模式下高亮文本不可见?
JUnit 5测试中的临时目录(附实例及代码)
Database indexes: indexes are not a panacea
Maxwell 一款简单易上手的实时抓取Mysql数据的软件
FFmpeg —— 将mp4转为gif输出(附源码)
After MySQL grouping, take the largest piece of data [optimal solution]
How to build FTP server under win2003
To the operation of the int variable assignment is atom?
PHP低代码开发平台 V5.0.7新版发布
Mac安装PHP开发环境
MySQL数据库主从配置
Brush questions record----string
MySQL kills 10 questions, how many questions can you stick to?