题意:有一堆兔子,还有一个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的更多相关文章

  1. FJ省队集训DAY3 T1

    思路:我们考虑如果取掉一个部分,那么能影响到最优解的只有离它最近的那两个部分. 因此我们考虑堆维护最小的部分,离散化离散掉区间,然后用线段树维护区间有没有雪,最后用平衡树在线段的左右端点上面维护最小的 ...

  2. FJ省队集训DAY5 T1

    思路:考试的时候打了LCT,自以为能过,没想到只能过80.. 考完一想:lct的做法点数是100W,就算是nlogn也会T. 讲一下lct的做法把:首先如果一条边连接的两个点都在同一个联通块内,那么这 ...

  3. FJ省队集训DAY4 T1

    直接上题解 #include<cstdio> #include<iostream> #include<cmath> #include<cstring> ...

  4. FJ省队集训DAY2 T1

    思路:转换成n条三维空间的直线,求最大的集合使得两两有交点. 有两种情况:第一种是以某2条直线为平面,这时候只要统计这个平面上有几条斜率不同的直线就可以了 还有一种是全部交于同一点,这个也只要判断就可 ...

  5. FJ省队集训DAY4 T3

    #include<cstdio> #include<iostream> #include<cmath> #include<cstring> #inclu ...

  6. FJ省队集训最终测试 T2

    思路:发现如果一个人一共选了x个点,那么选中某一个点对的概率都是一样的,一个人选x个点的总方案是C(n,x),一个人选中某个点对的总方案是C(n-2,x-2),这样,那么选中某个点对的概率就是 x*( ...

  7. FJ省队集训最终测试 T3

    思路:状态压缩dp,f[i][j[[k]代表i行j列这个格子,连续的状态为k,这个连续的状态是什么?就是下图 X格子代表我当前走到的地方,而这里的状态就是红色部分,也就是连续的一段n的状态,我们是分每 ...

  8. FJ省队集训DAY4 T2

    XXX #include<cstdio> #include<iostream> #include<cmath> #include<cstring> #i ...

  9. FJ省队集训DAY3 T2

    思路:如果一个DAG要的路径上只要一条边去切掉,那么要怎么求?很容易就想到最小割,但是如果直接做最小割会走出重复的部分,那我们就这样:反向边设为inf,这样最小割的时候就不会割到了,判断无解我们直接用 ...

随机推荐

  1. HDOJ(HDU) 1406 完数

    Problem Description 完数的定义:如果一个大于1的正整数的所有因子之和等于它的本身,则称这个数是完数,比如6,28都是完数:6=1+2+3:28=1+2+4+7+14. 本题的任务是 ...

  2. bzoj4096 [Usaco2013 dec]Milk Scheduling

    Description Farmer John has N cows that need to be milked (1 <= N <= 10,000), each of which ta ...

  3. Subarray Sum Closest

    Question Given an integer array, find a subarray with sum closest to zero. Return the indexes of the ...

  4. JS-Date日期内置对象

    1.基本用法 <script> var date = new Date(); document.write(date+"<br/>");//获取具体时间 d ...

  5. iOS--九宫格布局

    [self rankWithTotalColumns: andWithAppW: andWithAppH:]; //九宫格布局 - (void)rankWithTotalColumns:(int)to ...

  6. [深入React] 9.小技巧

    如果组件没有state那就可以精简成一个render function var Item = function(props){ return _('div',null,'名称:'+props.name ...

  7. lesson5:Condition的原理分析及demo展示

    Condition 将 Object 监视器方法(wait,notify,和notifyAll)分解成截然不同的对象,以便通过将这些对象与任意Lock实现组合使用,为每个对象提供多个等待 set(wa ...

  8. Gulp 简单的开发环境搭建

    //获取gulp //require()是 node (CommonJS)中获取模块的语法 var gulp=require('gulp'); //获取gulp-concat模块(用于合并文件):np ...

  9. UVAlive 6131 dp+斜率优化

    这道题和06年论文<从一类单调性问题看算法的优化>第一道例题很相似. 题意:给出n个矿的重量和位置,这些矿石只能从上往下运送,现在要在这些地方建造m个heap,要使得,sigma距离*重量 ...

  10. 常用元素的属性/方法 attr / val / html /text

    常用元素的属性/方法 得到一个元素的高度, $("#myid").height() 得到一个元素的位置, $("#myid").offset() 返回的是一个o ...