bzoj 4206 最大团 几何+lis
最大团
Time Limit: 10 Sec Memory Limit: 256 MB
Submit: 142 Solved: 65
[Submit][Status][Discuss]
Description
Input
Output
Sample Input
0 6
-7 -4
-3 -2
7 -5
-2 3
8 -3
Sample Output
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的更多相关文章
- BZOJ 4206: 最大团
4206: 最大团 Time Limit: 10 Sec Memory Limit: 256 MBSubmit: 91 Solved: 36[Submit][Status][Discuss] De ...
- BZOJ 1049 数字序列(LIS)
题目链接:http://www.lydsy.com:808/JudgeOnline/problem.php?id=1049 题意:给出一个数列A,要求:(1)修改最少的数字使得数列严格递增:(2)在( ...
- BZOJ 1046 [HAOI2007]上升序列(LIS + 贪心)
题意: m次询问,问下标最小字典序的长度为x的LIS是什么 n<=10000, m<=1000 思路: 先nlogn求出f[i]为以a[i]开头的LIS长度 然后贪心即可,复杂度nm 我们 ...
- BZOJ 1046: [HAOI2007]上升序列 LIS -dp
1046: [HAOI2007]上升序列 Time Limit: 10 Sec Memory Limit: 162 MBSubmit: 3438 Solved: 1171[Submit][Stat ...
- BZOJ 1046: [HAOI2007]上升序列(LIS)
题目挺坑的..但是不难.先反向做一次最长下降子序列.然后得到了d(i),以i为起点的最长上升子序列,接下来贪心,得到字典序最小. ----------------------------------- ...
- BZOJ 1091--切割多边形(几何&枚举)
1091: [SCOI2003]切割多边形 Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 356 Solved: 157[Submit][Status ...
- bzoj 1132 [POI2008]Tro 几何
[POI2008]Tro Time Limit: 20 Sec Memory Limit: 162 MBSubmit: 1796 Solved: 604[Submit][Status][Discu ...
- bzoj AC倒序
Search GO 说明:输入题号直接进入相应题目,如需搜索含数字的题目,请在关键词前加单引号 Problem ID Title Source AC Submit Y 1000 A+B Problem ...
- bzoj3663
几何+lis 很巧妙.直接做很困难,那么我们转化一下,把每个点能看见的圆弧画出来.只有这些圆弧相交时才满足条件. 那么也就是找出圆上尽量多两两相交的区间. 所以我们先按左端点极角排序,然后固定一个必须 ...
随机推荐
- sparksql读写hbase
//写入hbase(hfile方式) org.apache.hadoop.hbase.client.Connection conn = null; try { SparkLog.debug(" ...
- Matlab 图象操作函数讲解
h = imrect;pos = getPosition(h); 这个函数用来获取图象上特定区域的坐标,其中pos的返回值中有四个参数[xmin,ymin,width,height],特定区域的左上角 ...
- solidity事件详解
很多同学对Solidity 中的Event有疑问,这篇文章就来详细的看看Solidity 中Event到底有什么用? 写在前面 Solidity 是以太坊智能合约编程语言,阅读本文前,你应该对以太坊. ...
- HDU 2489 Minimal Ratio Tree(暴力+最小生成树)(2008 Asia Regional Beijing)
Description For a tree, which nodes and edges are all weighted, the ratio of it is calculated accord ...
- c++ string需要注意的地方
There are multiple answers based on what you are doing with the string. 1) Using the string as an id ...
- 进程间通信:命名管道FIFO(2)
一.命名管道 如果我们想在不相关的进程之间交换数据,可以用FIFO文件来完成这项工作,它通常也被称为命名管道.命名管道是一种特殊类型的文件,它在文件系统中以文件名的形式存在,但是它的行为却和我们已经见 ...
- java — JVM调优
数据类型 Java虚拟机中,数据类型可以分为两类:基本类型和引用类型.基本类型的变量保存原始值,即:他代表的值就是数值本身:而引用类型的变量保存引用值.“引用值”代表了某个对象的引用,而不是对象本身, ...
- ACM 第十二天
博弈论(巴什博奕,威佐夫博弈,尼姆博弈,斐波那契博弈,SG函数,SG定理) 一. 巴什博奕(Bash Game): A和B一块报数,每人每次报最少1个,最多报4个,看谁先报到30.这应该是最古老的关 ...
- LintCode-5.第k大元素
第k大元素 在数组中找到第k大的元素 注意事项 你可以交换数组中的元素的位置 样例 给出数组 [9,3,2,4,8],第三大的元素是 4 给出数组 [1,2,3,4,5],第一大的元素是 5,第二大的 ...
- 《学习OpenCV》课后习题解答1
题目:(P104) 下面这个练习是帮助掌握矩阵类型.创造一个三通道二维矩阵,字节类型,大小为100*100,并设置所有数值为0. a.在矩阵中使用cvCircle( CvArr* img, CvPoi ...