当前位置:网站首页>【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;
}
边栏推荐
- 银行数据资产转换能力弱?思迈特软件助力解决银行困境
- mysql慢查询优化
- Ordinary int main(){} does not write return 0; what will happen?
- [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
- 从离线到实时对客,湖仓一体释放全量数据价值
- Frog jumping steps (recursive and non-recursive) ------- Xiaolele walks the steps
- el-input can only input integers (including positive numbers, negative numbers, 0) or only integers (including positive numbers, negative numbers, 0) and decimals
- Is the iPhone really thirteen incense?The two generations of products are completely compared, perhaps the previous generation is more worth buying
- Common Expression Recognition Based on Face (1) - Basic Knowledge of Deep Learning
- Multi-threaded mutex application RAII mechanism
猜你喜欢

360杜跃进:太空安全风险加剧,需打造一体化防御体系

【PM专用】快速统计团队还有谁没有登记上报信息,快速筛选出属于自己项目组的成员,未完成XXX工作事项的名单

多线程的互斥锁应用RAII机制

PHP低代码开发平台 V5.0.7新版发布

MySQL数据库主从配置

Cesium loads offline maps and offline terrain

MySQL Functions (Classic Collection)

The technology is very powerful, do you still need to "manage up"?

KEIL问题:【keil Error: failed to execute ‘C:\Keil\ARM\ARMCC‘】

推荐系统:概述【架构:用户/物品特征工程---->召回层---->排序层---->测试/评估】【冷启动问题、实时性问题】
随机推荐
Different lower_case_table_names settings for server (‘1‘) and data dictionary (‘0‘) 解决方案
Cesium加载离线地图和离线地形
Maxwell 一款简单易上手的实时抓取Mysql数据的软件
线性结构:栈和队列
推荐系统:评估指标【离线评估指标:RMSE(均方根误差)、AUC、准确率、召回率、F1】【在线评估:A/B测试】【一般要求响应时间<0.5s】
银行数据资产转换能力弱?思迈特软件助力解决银行困境
TensorFlow2: Overview
[NISACTF 2022]下
Recommendation System - Sorting Layer: Sorting Layer Architecture [User and Item Feature Processing Steps]
[Node implements data encryption]
Linux下安装Mysql5.7,超详细完整教程,以及云mysql连接
How to install and use PostgreSQL 14.4
Centos7 install mysql8
基于人脸的常见表情识别(1)——深度学习基础知识
Swift简介
MySQL大总结
SQLyog注释 添加 撤销 快捷键
MySQL performance optimization (hardware, system configuration, table structure, SQL statements)
OSS简单上传图片
FFmpeg —— 裁剪视频(含音视频),不需编解码(附完整源码)