bzoj3663
几何+lis
很巧妙。直接做很困难,那么我们转化一下,把每个点能看见的圆弧画出来。只有这些圆弧相交时才满足条件。
那么也就是找出圆上尽量多两两相交的区间。
所以我们先按左端点极角排序,然后固定一个必须选的区间,找出所有和它相交的区间,按右端点做lis就行了。
#include<bits/stdc++.h>
using namespace std;
const int N = ;
const double pi = acos(-);
struct data {
double l, r;
int id;
} x[N], a[N];
int n, ans;
double R;
int tree[N << ], dp[N];
void update(int l, int r, int x, int pos, int t)
{
if(l == r)
{
tree[x] = t;
return;
}
int mid = (l + r) >> ;
if(pos <= mid)
update(l, mid, x << , pos, t);
else
update(mid + , r, x << | , pos, t);
tree[x] = max(tree[x << ], tree[x << | ]);
}
int query(int l, int r, int x, int a, int b)
{
if(l > b || r < a)
return ;
if(l >= a && r <= b)
return tree[x];
int mid = (l + r) >> ;
return max(query(l, mid, x << , a, b),
query(mid + , r, x << | , a, b));
}
int lis(int t)
{
if(!t) return ;
int ans = ;
dp[] = ;
memset(tree, , sizeof(tree));
update(, n, , x[].id, dp[]);
for(int i = ; i <= t; ++i)
{
dp[i] = query(, n, , , x[i].id) + ;
ans = max(ans, dp[i]);
update(, n, , x[i].id, dp[i]);
}
return ans;
}
bool cp1(data x, data y)
{
return x.r < y.r;
}
bool cp(data x, data y)
{
return x.l < y.l;
}
int main()
{
scanf("%d%lf", &n, &R);
for(int i = ; i <= n; ++i)
{
double x, y; scanf("%lf%lf", &x, &y);
double degx = atan2(y, x);
double degc = acos(R / sqrt(x * x + y * y));
a[i].l = degx - degc;
a[i].r = degx + degc;
while(a[i].l <= -pi)
a[i].l += * pi;
while(a[i].r >= pi)
a[i].r -= * pi;
if(a[i].l > a[i].r)
swap(a[i].l, a[i].r);
}
sort(a + , a + n + , cp1);
for(int i = ; i <= n; ++i)
a[i].id = i;
sort(a + , a + n + , cp);
for(int i = ; i <= n; ++i)
{
int t = ;
for(int j = i + ; j <= n; ++j)
if(a[j].l <= a[i].r && a[j].r >= a[i].r)
x[++t] = a[j];
ans = max(ans, lis(t) + );
}
printf("%d\n", ans);
return ;
}
bzoj3663的更多相关文章
- bzoj3663/4660CrazyRabbit && bzoj4206最大团
题意 给出平面上N个点的坐标,和一个半径为R的圆心在原点的圆.对于两个点,它们之间有连边,当且仅当它们的连线与圆不相交.求此图的最大团. 点数<=2000,坐标的绝对值和半径<=5000. ...
- Bzoj3663/4660 CrazyRabbit
题意:给定平面上一个圆和一堆圆外的点,要求选出尽可能多的点使得它们之间两两连线都不和圆相交.保证任意两点连线不和圆相切.点数<=2000 这题是很久以前在某张课件上看见的.看了题解还搞了三小时, ...
- 三倍经验——bzoj3663、4660、4206 Crazy Rabbit/最大团
题目描述: 3663 4660 4206 题解: 第一眼:不成立的互相连边,然后用网络流求解无向图最小点覆盖! 好吧我不会. 正解: 每个点对应圆上的一段圆弧,长这样: 设对应圆弧$(l,r)$. 若 ...
随机推荐
- 继 S-HR之代码创建临时表并插入数据 完整功能之员工职业信息变更报表
目的示例1: 制作员工职业信息报表[S-HR系统的报表其实就是列表o.0,醉了] EcirrWithPP.js shr.defineClass("shr.custom.EcirrWithPP ...
- Intel要在中国投35亿美金造这种闪存,3DxPoint技术牛在哪里?
Repost: https://www.leiphone.com/news/201508/bbCUJqS2M3glCY3m.html 编者按: 今年的IDF上,Intel 再次强调了3DxPoint闪 ...
- php第三十节课
文件操作 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3 ...
- WebBrowser之获取跳转页面的Document接口源码
问题由来是这样的,今天帮一个网友解决问题,说从VC驿站下载了一个源码,程序的功能主要是在对话框上面放置了一个WebBrowser控件,程序启动的时候默认调用这句代码: m_web.Navigate(_ ...
- (六)python3 字符串常用方法
字符串截取 >>>s = 'hello' >>>s[0:3] 'he' >>>s[:] #截取全部字符 'hello' 消除空格及特殊符号 ...
- window7 上创建定时任务来运行自动化脚本
跌跌撞撞,坑坑洼洼,终于把公司一个小模块的接口测试脚本写完了,一共有20多个吧!后来发现每天自己去运行一键执行的脚本太麻烦,所以想用windows的定时任务来解决这个问题!今天看了篇文章,所以决定实践 ...
- 洛谷 2921 [USACO08DEC]在农场万圣节Trick or Treat on the Farm
[题解] 就是基环外向树森林找环,然后从环向外统计size就可以了. #include<cstdio> #include<cstring> #include<algori ...
- BNUOJ 2528 Mayor's posters
Mayor's posters Time Limit: 3000ms Memory Limit: 131072KB This problem will be judged on UVA. Origin ...
- HDU 1249 三角形的分割
可以将三角形的三条边一条一条加进图形中观察 假设添加第n个三角形 前n-1个三角形将区域划分为sum[n-1] 第n个三角形每条边最多能经过前n-1个三角形每条三角形的两条边 , 一条边切完增加了 2 ...
- poj 3237 树链剖分模板(用到线段树lazy操作)
/* 本体在spoj375的基础上加了一些操作,用到线段树的lazy操作模板类型 */ #include<stdio.h> #include<string.h> #includ ...