hdu 5738 Eureka 极角排序+组合数学
Eureka
Time Limit: 8000/4000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 2317 Accepted Submission(s): 678
A set P (P contains the label of the points) is called best set if and only if there are at least one best pair in P. Two numbers u and v (u,v∈P,u≠v) are called best pair, if for every w∈P, f(u,v)≥g(u,v,w), where f(u,v)=(xu−xv)2+(yu−yv)2−−−−−−−−−−−−−−−−−−√ and g(u,v,w)=f(u,v)+f(v,w)+f(w,u)2.
The first line contains an integer n (1≤n≤1000) -- then number of points.
Each of the following n lines contains two integers xi and yi (−109≤xi,yi≤109) -- coordinates of the i-th point.
3
1 1
1 1
1 1
3
0 0
0 1
1 0
1
0 0
3
0
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <set>
using namespace std;
typedef long long ll;
typedef unsigned long long Ull;
#define MM(a,b) memset(a,b,sizeof(a));
const double eps = 1e-10;
const int inf =0x7f7f7f7f;
const double pi=acos(-1);
const int mod=1e9+7;
const int maxn=100000+10;
ll f_2[1000+10]; struct Point{
int x,y;
}p[1000+10]; struct Ang{
double a;
ll x,y;
}ang[1000+10]; bool cmpxy(Point a,Point b)
{
if(a.x!=b.x) return a.x<b.x;
else return a.y<b.y;
} bool cmpang(Ang a,Ang b){
return a.a<b.a;
} int main()
{
f_2[0]=1;
for(int i=1;i<=1000;i++) f_2[i]=(f_2[i-1]*2)%mod;
int cas,n;
scanf("%d",&cas);
while(cas--)
{
ll ans=0;
scanf("%d",&n);
for(int i=1;i<=n;i++) scanf("%d %d",&p[i].x,&p[i].y);
sort(p+1,p+n+1,cmpxy); int i,j,k,l,num;
for(i=1;i<n;i++)
{
for(j=i+1;j<=n;j++)
{
if(p[j].x==p[i].x&&p[j].y==p[i].y) continue;
else break;
}
j--;
int s=j-i+1,cnt=0,d=0;
ans=(ans+f_2[s]-1-s)%mod;
for(k=j+1;k<=n;k++)
{
ang[++cnt].a=atan2((double)(p[k].y-p[i].y),(double)(p[k].x-p[i].x));
ang[cnt].x=p[k].x;
ang[cnt].y=p[k].y;
} sort(ang+1,ang+cnt+1,cmpang);
for(k=1;k<=cnt;k++){ for(l=k+1;l<=cnt;l++)
if((ang[l].y-p[i].y)*(ang[k].x-p[i].x)!=
(ang[k].y-p[i].y)*(ang[l].x-p[i].x))
{d++;break;}
l--;
num=l-k+1;
ans=(ans+((f_2[s]-1)*(f_2[num]-1))%mod)%mod;
k=l;
} i=j;
}
printf("%lld\n",ans%mod);
}
return 0;
}
思路:先对所有的点进行坐标排序,然后依次枚举每个点,先筛选出与其重合的点,然后,
再依次为基点,求得没有枚举过得点相对这个点的角度,再进行极角排序,合并共线的点(这个
判断共线容易错。不能直接根据相对基点角度(double型)是否相等来判断,可以直接用向量
共线的坐标,变成相乘的形式)
hdu 5738 Eureka 极角排序+组合数学的更多相关文章
- HDU 5738 Eureka(极角排序)
[题目链接] http://acm.hdu.edu.cn/showproblem.php?pid=5738 [题目大意] 给出平面中一些点,在同一直线的点可以划分为一个集合,问可以组成多少包含元素不少 ...
- HDU 5738 Eureka 统计共线的子集个数
Eureka 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5738 Description Professor Zhang draws n poin ...
- HDU 5738 Eureka
传送门 题目大意: 给出平面上的$n$个点,每个点有唯一的标号($\text{label}$),这$n$个标号的集合记作$S$,点可能重合.求满足下列条件的$S$的子集$T$的数目: 1. $|T|\ ...
- hdu-5738 Eureka(组合计数+极角排序)
题目链接: Eureka Time Limit: 8000/4000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Pr ...
- 【极角排序+双指针线性扫】2017多校训练七 HDU 6127 Hard challenge
acm.hdu.edu.cn/showproblem.php?pid=6127 [题意] 给定平面直角坐标系中的n个点,这n个点每个点都有一个点权 这n个点两两可以连乘一条线段,定义每条线段的权值为线 ...
- HDU Always Cook Mushroom (极角排序+树状数组)
Problem Description Matt has a company, Always Cook Mushroom (ACM), which produces high-quality mush ...
- 2017ACM暑期多校联合训练 - Team 7 1008 HDU 6127 Hard challenge (极角排序)
题目链接 Problem Description There are n points on the plane, and the ith points has a value vali, and i ...
- HDU 6538 Neko and quadrilateral(极角排序+旋转坐标系)
这道题简直太好了,对于计算几何选手需要掌握的一个方法. 首先对于求解四边形面积,我们可以将四边形按对角线划分成两个三角形,显然此时四边形的面积最大最小值就变成了求解里这个对角线最近最远的点对. 对于此 ...
- poj2280Amphiphilic Carbon Molecules(极角排序)
链接 卡了几天的破题,对于hdu的那份数据,这就一神题.. 借助极角排序,枚举以每一个点进行极角排序,然后构造两条扫描线,一个上面一个下面,两条同时走,把上线和下线的点以及上线左边的点分别统计出来,如 ...
随机推荐
- 牛客 110D 矩阵
假设$C=AB$, 那么答案就为 $\begin{align} \notag ans & =\sum\limits_{i=0}^{n-1}\sum\limits_{j=0}^{n-1}C[i] ...
- DVWA reCAPTCHA key: Missing
修改dvwa文件夹下文件config.inc.php change: $_DVWA[ 'recaptcha_public_key' ] = ' '; $_DVWA[ 'recaptcha_privat ...
- 学生管理系统利用arrayList第二次优化
package StuManage; public class Student { private String name;//姓名 private String stuNum;//学号 privat ...
- ASP.NET使用AJAX应注意IIS有没有.ashx扩展
项目添加引用AJAX.DLL了:今天将本地做好的一个web程序放到服务器上,居然报告错误了.web程序使用了ajax来往返数据. 检查生成的html语句,有这么两句代码<script type= ...
- json返回数据多个是数组,单个就不是处理方案
/// <summary> /// 计算方案 当前返回的对象 /// </summary> [JsonConverter(ty ...
- O028、nova-compute 部署 instance 详解
参考https://www.cnblogs.com/CloudMan6/p/5451276.html 本节讨论 nova-compute ,并详细分析 instance 部署的全过程. nov ...
- kbmMW 5.09测试报告(1)-Scheduler
这个版本除了增加新的SmartBinding功能,同时提供了大量的功能更新以及bug修正.其中,SmartBinding的介绍,xalion已经第一时间写了初识kbmmw 中的smartbind功能, ...
- JavaWeb【四、JSP基础语法】
简介 JSP--Java Server Pages,根本是一个简化的Servlet设计,实现了在Java中使用HTML标签. 特点 跨平台,安全性好,大型站点开发,企业级Web应用,大数据. 对比: ...
- 百度编辑神器ueditor在ajax或form提交内容时候异常
百度编辑神器ueditor在ajax或form提交内容时候异常,一:⑴web.config中<system.web> <httpRuntime requestValidationMo ...
- oracle修改已存在数据的字段类型
第一次使用oracle数据库,在通过Navicat premium工具修改字段类型时,发现报“ORA-01439: column to be modified must be empty to cha ...