最大团

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. 【CSVRead】-jmeter

    csv     read 读取文件

  2. 【转】VSstudio中的一些宏

    说明 $(RemoteMachine) 设置为“调试”属性页上“远程计算机”属性的值.有关更多信息,请参见更改用于 C/C++ 调试配置的项目设置. $(References) 以分号分隔的引用列表被 ...

  3. 微信小程序 选项 、时间日期选择器

    wxml: <view class="section" > <picker bindchange="bindPickerChange" val ...

  4. jQuery 对象 与 原生 DOM 对象 相互转换

    区别 jQuery 选择器得到的 jQuery对象 和 原生JS 中的document.getElementById() document.querySelector取得的 DOM对象 是两种不同类型 ...

  5. 90 [LeetCode] Subsets2

    Given a collection of integers that might contain duplicates, nums, return all possible subsets (the ...

  6. Thunder团队第三周 - Scrum会议1

    Scrum会议1 小组名称:Thunder 项目名称:i阅app Scrum Master:王航 工作照片: 杨梓瑞在拍照,所以不在照片中. 参会成员: 王航(Master):http://www.c ...

  7. 重构 之 总结代码的坏味道 Bad Smell (一) 重复代码 过长函数 过大的类 过长参数列 发散式变化 霰弹式修改

    膜拜下 Martin Fowler 大神 , 开始学习 圣经 重构-改善既有代码设计 . 代码的坏味道就意味着需要重构, 对代码的坏味道了然于心是重构的比要前提; . 作者 : 万境绝尘 转载请注明出 ...

  8. unordered_map(hash_map)和map的比较

    测试代码: #include <iostream> using namespace std; #include <string> #include <windows.h& ...

  9. ASP.NET 使用MVC4的EF5 Code First 入门(一):创建数据库

    一.基本流程 建立模型→建立控制器→EF框架自动生成视图的数据库 二.基本理论 1.约定优于配置(Convention Over Configuration) 设计不好的框架通常需要多个配置文件,每一 ...

  10. Gitkraken系列-Gitkraken修改用户名

    修改用户名 为了方便项目中代码的管理,需要重新编辑用户名. 点击右上角的图像即可看到如下图 3‑1所示的下拉菜单,鼠标悬于Profile上,会出现一个Edit按钮. 图 3‑1 编辑个人信息 点击Ed ...