Racing Gems
来源:互联网 发布:什么是中文域名 编辑:程序博客网 时间:2024/06/10 19:10
挺显然是个dp,但是状态应该怎么转移才是问题。考虑点 i 能够转移到点 j,必定是点 j 包含在点 i 的一个弧度角中。再转化一下,就是通过反向的投影,点 j 一定在点 i 的两端
于是我们将点向左投影进行排序,并且从大到小打上id 1~n,在这个偏序关系中,状态只能从编号小的转移到编号大的(即投影后横坐标大的能转移到横坐标小的);再将点向右投影并且从小到大排序,同理状态只能从前面的转移到后面的,合起来就是当前序列只能从前面而且id比自己小的转移,套上树状数组就好了。
#include <bits/stdc++.h>using namespace std;const int maxn = 100010;const double eps = 1e-9;struct Point { double x, y; int id; Point() {} Point(double xx, double yy, int ii): x(xx), y(yy), id(ii) {}};Point a[maxn];int f[maxn], n, ans, t;double r, w, h;bool cmp1(const Point p1, const Point p2) { double x1 = (r*p1.x-p1.y)/r; double x2 = (r*p2.x-p2.y)/r; if (fabs(x1-x2) < eps) { if (p1.y < p2.y) return true; return false; } if (x1 > x2) return true; return false;}bool cmp2(const Point p1, const Point p2) { double x1 = (p1.y+r*p1.x)/r; double x2 = (p2.y+r*p2.x)/r; if (fabs(x1-x2) < eps) { if (p1.y < p2.y) return true; return false; } if (x1 < x2) return true; return false;}void insert(int x, int y) { while (x < maxn) { f[x] = max(f[x], y); x = x+(x & (-x)); }}int find(int x) { int t = 0; while (x > 0) { t = max(t, f[x]); x = x-(x & (-x)); } return t;}int main() { freopen("input.txt","r",stdin); scanf("%d %lf %lf %lf", &n, &r, &w, &h); for (int i = 1; i <= n; i++) { scanf("%lf %lf", &a[i].x, &a[i].y); } sort(a+1, a+1+n, cmp1); for (int i = 1; i <= n; i++) a[i].id = i; sort(a+1, a+1+n, cmp2); for (int i = 1; i <= n; i++) { int t = find(a[i].id); ans = max(ans, t+1); insert(a[i].id, t+1); } printf("%d\n", ans);}
阅读全文
0 0
- Racing Gems
- 二维LIS Gym100820G Racing Gems
- GYM 100820 G.Racing Gems(LIS)
- Gym-100820 Racing Gems(二维LIS)
- Gym100820G/UVALive7374 Racing Gems 二维LIS 思维题
- UVALive 7374 Racing Gems (最长上升子序列--二分法)
- UVALive 7374 Racing Gems - dp,最长上升子序列
- gym 100820G Racing Gems(二维LIS,好题)
- UVALive-7374-Racing Gems(最长上升子序列O(n*logn))
- HDU 6199 gems gems gems
- hdu 6199 gems gems gems
- 【2015-2016 ACM-ICPC Pacific Northwest Regional Contest (Div 1)G】【坐标轴变换 LIS】Racing Gems 开车吃宝石,横向速度不能超
- HDU 6199 gems gems gems dp
- hdu 6199 gems gems gems dp
- hdu 6199 gems gems gems(DP)
- Ruby Gems
- HDU 6199 gems gems gems 2017沈阳网络赛 1006
- HDU 6199 gems gems gems (2017沈阳网络赛)
- LeedCode ZigZag Conversion
- 【实战】4-8 项目包结构初始化
- 设计模式-行为-备忘录
- less语法介绍
- UVAlive6620 Josephina and RPG
- Racing Gems
- <C语言>auto和register关键字
- ST表求区间最大最小值
- Android WiFi功能实现,知其然必知其所以然!(一)
- Atom不能补全原生JS的一些DOM函数
- Leetcode之Construct String from Binary Tree 问题
- IO Streams:来源于命令行的IO
- codeforces 869C. The Intriguing Obsession(组合数学)
- JAVA6