当前位置:网站首页>【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;
}
边栏推荐
- Linux下安装Mysql5.7,超详细完整教程,以及云mysql连接
- Cesium loads offline maps and offline terrain
- MySQL six-pulse sword, SQL customs clearance summary
- M3SDA:用于多源域自适应的矩匹配
- 线性结构:顺序表和链表
- 【无标题】多集嵌套集合使不再有MultipleBagFetchException
- PHP低代码开发引擎—表单设计
- MySql密码
- TensorFlow2:概述
- 推荐系统:评估指标【离线评估指标:RMSE(均方根误差)、AUC、准确率、召回率、F1】【在线评估:A/B测试】【一般要求响应时间<0.5s】
猜你喜欢
DCM 中间件家族迎来新成员
KEIL problem: [keil Error: failed to execute 'C:\Keil\ARM\ARMCC']
excel数字下拉递增怎么设置?
MySQL数据库 ---MySQL表的增删改查(进阶)
MySQL database --- Addition, deletion, modification and query of MySQL tables (advanced)
推荐系统:冷启动问题【用户冷启动、物品冷启动、系统冷启动】
Recommender systems: overview of the characteristics of architecture: user/item engineering -- -- -- -- -- -- -- -- > recall layer > sort layer - > test/evaluation 】 【 cold start problems, real-time 】
如何优化OpenSumi终端性能?
Database indexes: indexes are not a panacea
Weak Banks to data conversion ability?Matt software help solve bank dilemma
随机推荐
Database Tuning - Database Tuning
.eslintrc.js for musicApp
MySQL数据库 ---MySQL表的增删改查(进阶)
为单行查询设置JDBC Statement.setFetchSize()为1的方法指南
Office365无法打开word文档怎么办?Office365无法打开word文档的解决方法
ECCV2022 | 对比视觉Transformer的在线持续学习
湖仓一体电商项目(四):项目数据种类与采集
TensorFlow2:概述
PostgreSQL 14.4如何安装使用
Swift简介
Can't find the distributed lock of Redisson?
MySQL大总结
el-input 只能输入整数(包括正数、负数、0)或者只能输入整数(包括正数、负数、0)和小数
MySQL performance optimization (hardware, system configuration, table structure, SQL statements)
MySql密码
Snowflake vs. Redshift的2022战报:两个数据平台谁更适合你?
我是一名阿里在职9年软件测试工程师,我的经历也许能帮到处于迷茫期的你
时间复杂度与空间复杂度
WPS表格怎么自动1234排下去?wps表格怎么自动生成序号?
MySQL函数(经典收藏)