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,这样最小割的时候就不会割到了,判断无解我们直接用 ...
随机推荐
- sigaction 用法实例
sigaction函数的功能是检查或修改与指定信号相关联的处理动作(可同时两种操作). 他是POSIX的信号接口,而signal()是标准C的信号接口(如果程序必须在非POSIX系统上运行,那么就应该 ...
- MD中bitmap源代码分析--清除流程
bitmap的清零是由bitmap_daemon_work()来实现的.Raid1守护进程定期执行时调用md_check_recovery,然后md_check_recovery会调用bitmap_d ...
- LeetCode 6. ZigZag Conversion Question
题意:给你一个字符串和行数numRows,要求把该字符串变成一个"之"字形状后,按行数输出该字符串. 例子:"ABCDEFGHIJKLMNO", 4. 该字符串 ...
- 执行npm安装模块的命令 Cannot find module
npm 安装了 appium 和 appium-doctor 运行命令,appium-doctor 提示找不到模块: C:\Users\autotest>appiummodule.js:471 ...
- Python进阶(面向对象编程基础)(四)
1.方法也是属性 我们在 class 中定义的实例方法其实也是属性,它实际上是一个函数对象: class Person(object): def __init__(self, name, score) ...
- HybridApp开发准备工作——WebView
如大家所见,手机真是越来越离不开我们的日常生活了,像我,现在出门必带的是手机.移动电源.公交卡:钱包什么的再也没出过门.两年前,我还在Android的应用开发中当了一次过客.嗯,当时JAVA学得太糟糕 ...
- Android设置上下边框或者左右边框
<?xml version="1.0" encoding="utf-8"?> <com.sunskyjun.fwproject.widgts. ...
- 使用awrextr.sql导出awr原始数据
1.AWR原始数据与AWR报告的差别 AWR原始数据: 是oracle数据库mmon进程定期将统计量从内存转储至磁盘,并以结构化的形式存入若干张表组成自己主动工作负荷存储仓库(AutomaticWor ...
- Ubuntu安装配置Qt环境
安装 QT4.8.6库+QT Creator 2.4.1 下载地址发布 QT4.8.6库 http://mirrors.hustunique.com/qt/official_releases/qt/ ...
- [MVC4-基礎] 從資料庫取值顯示在DropDownList中
剛開始學MVC4,以下是一些基礎的學習筆記! 完成效果像下面這樣,資料來源是既有的Database. 1.Controller public ActionResult Index() { SqlCon ...