最大团

Time Limit: 10 Sec  Memory Limit: 256 MB
Submit: 142  Solved: 65
[Submit][Status][Discuss]

Description

给出平面上N个点的坐标,和一个半径为R的圆心在原点的圆。对于两个点,它们之间有连边,当且仅当它们的连线与圆不相交。
求此图的最大团。
 

Input

第一行两个整数N和R, 表示点数和圆的半径。
接下来N 行,每行两个整数xi 和yi,表示第i个点的坐标
保证每个点都严格在园外,且两两直线不与圆相切。
 

Output

输出一个整数:最大团的大小。
 

Sample Input

6 3
0 6
-7 -4
-3 -2
7 -5
-2 3
8 -3

Sample Output

4

HINT

对于100%的数据,1≤N≤2000,|xi|,|yi|,R≤5000

 #include<cstring>
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<queue>
#include<map> #define N 2007
#define pi acos(-1)
#define inf 1000000007
using namespace std;
inline int read()
{
int x=,f=;char ch=getchar();
while(!isdigit(ch)){if(ch=='-')f=-;ch=getchar();}
while(isdigit(ch)){x=(x<<)+(x<<)+ch-'';ch=getchar();}
return x*f;
} int n,tot,st[N];
double r;
struct Node
{
double l,r;
Node()
{
l=r=;
}
friend bool operator<(Node x,Node y)
{
return x.l<y.l;
}
}a[N]; int getlis(int x)
{
st[tot=]=x,a[].r=-inf;
for (int i=x+;i<=n&&a[i].l<a[x].r;i++)
if (a[i].r>a[st[tot]].r) st[++tot]=i;
else
{
int l=,r=tot,ans=tot;
while(l<=r)
{
int mid=(l+r)>>;
if (a[st[mid]].r>=a[i].r) ans=min(mid,ans),r=mid-;
else l=mid+;
}
if (ans==) continue;
if (a[i].r<a[st[ans]].r) st[ans]=i;
}
return tot;
}
double get_dis(double x,double y)
{
return sqrt(x*x+y*y);
}
int main()
{
n=read(),r=read();
for (int i=;i<=n;i++)
{
double x=read(),y=read();
if (get_dis(x,y)<r){i--,n--;continue;}
a[i].l=atan2(y,x)-acos(r/get_dis(x,y));
a[i].r=atan2(y,x)+acos(r/get_dis(x,y));
if (a[i].r>pi) a[i].r-=*pi,swap(a[i].l,a[i].r);
if (a[i].l<-pi) a[i].l+=*pi,swap(a[i].l,a[i].r);
}
sort(a+,a+n+); int ans=;
for (int i=;i<=n;i++)
ans=max(ans,getlis(i));
printf("%d\n",ans);
}

bzoj 4206 最大团 几何+lis的更多相关文章

  1. BZOJ 4206: 最大团

    4206: 最大团 Time Limit: 10 Sec  Memory Limit: 256 MBSubmit: 91  Solved: 36[Submit][Status][Discuss] De ...

  2. BZOJ 1049 数字序列(LIS)

    题目链接:http://www.lydsy.com:808/JudgeOnline/problem.php?id=1049 题意:给出一个数列A,要求:(1)修改最少的数字使得数列严格递增:(2)在( ...

  3. BZOJ 1046 [HAOI2007]上升序列(LIS + 贪心)

    题意: m次询问,问下标最小字典序的长度为x的LIS是什么 n<=10000, m<=1000 思路: 先nlogn求出f[i]为以a[i]开头的LIS长度 然后贪心即可,复杂度nm 我们 ...

  4. BZOJ 1046: [HAOI2007]上升序列 LIS -dp

    1046: [HAOI2007]上升序列 Time Limit: 10 Sec  Memory Limit: 162 MBSubmit: 3438  Solved: 1171[Submit][Stat ...

  5. BZOJ 1046: [HAOI2007]上升序列(LIS)

    题目挺坑的..但是不难.先反向做一次最长下降子序列.然后得到了d(i),以i为起点的最长上升子序列,接下来贪心,得到字典序最小. ----------------------------------- ...

  6. BZOJ 1091--切割多边形(几何&枚举)

    1091: [SCOI2003]切割多边形 Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 356  Solved: 157[Submit][Status ...

  7. bzoj 1132 [POI2008]Tro 几何

    [POI2008]Tro Time Limit: 20 Sec  Memory Limit: 162 MBSubmit: 1796  Solved: 604[Submit][Status][Discu ...

  8. bzoj AC倒序

    Search GO 说明:输入题号直接进入相应题目,如需搜索含数字的题目,请在关键词前加单引号 Problem ID Title Source AC Submit Y 1000 A+B Problem ...

  9. bzoj3663

    几何+lis 很巧妙.直接做很困难,那么我们转化一下,把每个点能看见的圆弧画出来.只有这些圆弧相交时才满足条件. 那么也就是找出圆上尽量多两两相交的区间. 所以我们先按左端点极角排序,然后固定一个必须 ...

随机推荐

  1. 吴恩达j机器学习之过拟合

    五.编程作业: 见:https://www.cnblogs.com/tommyngx/p/9933803.html

  2. *.hbm.xml作用是什么

    实体与表的映射关系通过XML来描述的文件.在 hibernate.cfg.xml中管理,在项目启动的时候加载到内存. hbm指的是hibernate的映射文件 映射文件也称映射文档,用于向Hibern ...

  3. zookeeper启动配置

    zookeeper安装和配置详解 转载 2014年04月16日 14:36:31 16812 摘自:http://www.ibm.com/developerworks/cn/opensource/os ...

  4. 《学习OpenCV》课后习题解答3

    题目:(P104) 创建一个大小为100*100的三通道RGB图像.将它的元素全部置0.使用指针算法以(20,5)与(40,20)为项点绘制一个绿色平面. 解答: #include "cv. ...

  5. ZOJ 1909 I-Square

    https://vjudge.net/contest/67836#problem/I Given a set of sticks of various lengths, is it possible ...

  6. 【Docker 教程】- Docker 架构

    1.Docker 使用客户端-服务器 (C/S) 架构模式,使用远程API来管理和创建Docker容器. 2.Docker 容器通过 Docker 镜像来创建. 3.容器与镜像的关系类似于面向对象编程 ...

  7. listBox和pictureBox的使用

    重要属性:pictureBox中SizeMode可以更改图像显示的尺寸大小. using System; using System.Collections.Generic; using System. ...

  8. struts如何在Action类中操作request,session

    在servlet中,通过request.getparameter与setparameter来实现后端与前端jsp页面的数据交互,那么在struts中,也有几种方式来操作request,session实 ...

  9. 整理下本周工作中遇到的疑问;uid/euid/suid;docker镜像管理

    1.系统中的父子进程关系,以及docker是如何处理的这种父子进程关系,线上问题发现,子进程长时间得不到退出. 2.调用system系统调用发生了啥事情,发现大量的页表拷贝. 3.通过shell命令通 ...

  10. 【bzoj3886】[Usaco2015 Jan]Moovie Mooving 状态压缩dp+二分

    题目描述 Bessie is out at the movies. Being mischievous as always, she has decided to hide from Farmer J ...