FJ省队集训DAY1 T1
题意:有一堆兔子,还有一个r为半径的圆,要求找到最大集合满足这个集合里的兔子两两连边的直线不经过圆。
思路:发现如果有两个点之间连边不经过圆,那么他们到圆的切线会构成一段区间,那么这两个点的区间一定会有交集,形如s0 s1 e0 e1
同样的,如果是n个点,那就是s0 s1 s2..sn e0 e1 e2.. en
因此,我们枚举那个起始点,然后对于其他点我们按照s排序,对于e做最长上升子序列即可。时间复杂度O(n^2 logn)
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
const double pi = 3.14159265358979324;
double th1[], th2[], b[], x[], y[];
std::pair<std::pair<double, double>, int> a[];
int t[], t2[], f[], n;
std::vector<int> ansv;
double r;
int main() {
freopen("crazy.in", "r", stdin);
freopen("crazy.out", "w", stdout);
scanf("%d%lf", &n, &r);
for (int i = ; i < n; i++) {
scanf("%lf%lf", &x[i], &y[i]);
double th = atan2(y[i], x[i]);
double dth = acos(r / sqrt(x[i] * x[i] + y[i] * y[i]));
th1[i] = th + dth; if (th1[i] > pi) th1[i] -= *pi;
th2[i] = th - dth; if (th2[i] <= -pi) th2[i] += *pi;
if (th1[i] > th2[i]) std::swap(th1[i], th2[i]);
}
int ans = ;
ansv.push_back();
for (int i = ; i < n; i++) {
int l = , ans2 = -;
for (int j = ; j < n; j++)
if (i != j && (th1[j] < th1[i] || th1[j] > th2[i] || th2[j] < th1[i] || th2[j] > th2[i])
&& (th1[j] > th1[i] && th1[j] < th2[i] || th2[j] > th1[i] && th2[j] < th2[i])) {
if (th1[j] > th1[i] && th1[j] < th2[i]) {
a[l].first.first = th1[j] - th1[i];
a[l].first.second = th2[j] - th2[i];
} else {
a[l].first.first = th2[j] - th1[i];
a[l].first.second = th1[j] - th2[i];
}
if (a[l].first.second < ) a[l].first.second += *pi;
a[l].second = j;
l++;
}
std::sort(a, a + l);
for (int j = ; j < l; j++) b[j] = a[j].first.second;
std::sort(b, b + l);
for (int j = ; j <= l; j++) t[j] = ;
for (int j = ; j < l; j++) {
int p = std::lower_bound(b, b + l, a[j].first.second) - b + ;
int v = , v2 = -;
for (int k = p; k; k -= k&-k)
if (t[k] > v) v = t[k], v2 = t2[k];
v++;
f[a[j].second] = v2;
if (v+ > ans) ans = v+, ans2 = a[j].second;
for (int k = p; k <= l; k += k&-k)
if (t[k] < v) t[k] = v, t2[k] = a[j].second;
}
if (ans2 != -) {
ansv.clear();
while (ans2 != -)
ansv.push_back(ans2), ans2 = f[ans2];
ansv.push_back(i);
}
}
printf("%d\n", ans);
return ;
}
FJ省队集训DAY1 T1的更多相关文章
- FJ省队集训DAY3 T1
思路:我们考虑如果取掉一个部分,那么能影响到最优解的只有离它最近的那两个部分. 因此我们考虑堆维护最小的部分,离散化离散掉区间,然后用线段树维护区间有没有雪,最后用平衡树在线段的左右端点上面维护最小的 ...
- FJ省队集训DAY5 T1
思路:考试的时候打了LCT,自以为能过,没想到只能过80.. 考完一想:lct的做法点数是100W,就算是nlogn也会T. 讲一下lct的做法把:首先如果一条边连接的两个点都在同一个联通块内,那么这 ...
- FJ省队集训DAY4 T1
直接上题解 #include<cstdio> #include<iostream> #include<cmath> #include<cstring> ...
- FJ省队集训DAY2 T1
思路:转换成n条三维空间的直线,求最大的集合使得两两有交点. 有两种情况:第一种是以某2条直线为平面,这时候只要统计这个平面上有几条斜率不同的直线就可以了 还有一种是全部交于同一点,这个也只要判断就可 ...
- FJ省队集训DAY4 T3
#include<cstdio> #include<iostream> #include<cmath> #include<cstring> #inclu ...
- FJ省队集训最终测试 T2
思路:发现如果一个人一共选了x个点,那么选中某一个点对的概率都是一样的,一个人选x个点的总方案是C(n,x),一个人选中某个点对的总方案是C(n-2,x-2),这样,那么选中某个点对的概率就是 x*( ...
- FJ省队集训最终测试 T3
思路:状态压缩dp,f[i][j[[k]代表i行j列这个格子,连续的状态为k,这个连续的状态是什么?就是下图 X格子代表我当前走到的地方,而这里的状态就是红色部分,也就是连续的一段n的状态,我们是分每 ...
- FJ省队集训DAY4 T2
XXX #include<cstdio> #include<iostream> #include<cmath> #include<cstring> #i ...
- FJ省队集训DAY3 T2
思路:如果一个DAG要的路径上只要一条边去切掉,那么要怎么求?很容易就想到最小割,但是如果直接做最小割会走出重复的部分,那我们就这样:反向边设为inf,这样最小割的时候就不会割到了,判断无解我们直接用 ...
随机推荐
- [译] 新手和老手都将受益的JavaScript小技巧
这篇文章会分享一些鲜为人知但却很强大的JavaScript技巧, 各个级别的JavaScript开发者都会从中受益. 1. 用数组的length属性清空数组 我们知道在JS中对象类型是按引用传 ...
- HDOJ 1335 Basically Speaking(进制转换)
Problem Description The Really Neato Calculator Company, Inc. has recently hired your team to help d ...
- DVP
债券结算方式是指在债券结算业务中,债券的所有权转移或权利质押与相应结算款项的交收这两者执行过程中的不同制约形式.中央债券簿记系统中所设计的结算方式有:纯券过户.见券付款.见款付券.券款对付(DVP)四 ...
- PHP中字符串类型与数值类型混合计算
字符串转数值的规则 当一个字符串被当作一个数值来取值,其结果和类型如下: 如果该字符串没有包含 '.','e' 或 'E' 并且其数字值在整型的范围之内(由 PHP_INT_MAX 所定义),该字符串 ...
- c++11 : Local and Unnamed Types as Template Arguments
In N2402, Anthony Williams proposes that local types, and unnamed types be usable as template argume ...
- Cycling Label
Cycling Label 来源: github/BBCyclingLabel Licence: Apache 2.0 作者: Bruno de Carvalho 分类: 标签(Label) 平台: ...
- 强制转https
原文:http://blog.csdn.net/wzy_1988/article/details/8549290 需求简介 基于nginx搭建了一个https访问的虚拟主机,监听的域名是test.co ...
- 浏览器格式化JSON输出,thinkphp
1 //编写类方法用$this->ajaxReturn()返回数据 2 public function index(){ 3 $user = M('User'); 5 $data = $user ...
- 广播接收者 BroadcastReceiver 示例-1
广播机制概述 Android广播分为两个方面:广播发送者和广播接收者,通常情况下,BroadcastReceiver指的就是广播接收者.广播作为Android组件间的通信方式,可以使用的场景如下: 1 ...
- Mindset + Know-how+Concepture + Methodology+Technology
在做成都专案过程中深刻体会到一个IT全才应该具备Domain Know-how,拥有正确地理念是十分重要的, 我想只能是某几个领域,专案管理,专案运行中的各种手法,即Methodology,最后才是K ...