(AtCoder Grand Contest 019) C
来源:互联网 发布:台风莫兰蒂数据 编辑:程序博客网 时间:2024/05/21 22:31
题目链接:
题目大意:
数据范围:
解题思路:
外话:
详见代码:
#include <cstdio>#include <cstdlib>#include <cstring>#include <cmath>#include <algorithm>#include <map>#include <set>#include <queue>using namespace std;typedef long long LL;const int inf = 1 << 30;const LL INF = 1LL << 60;const int MaxN = 2e5;//const double PI = 3.1415926535897932384626;const double PI = acos(-1);LL sx, sy, tx, ty;int n, tot;double res;struct point{ LL x, y;}tmp[MaxN + 5];bool cmpx(point a, point b) { if(a.x == b.x) return a.y < b.y; else return a.x < b.x;}//----------------LIS---------------------int len;LL a[MaxN + 5], d[MaxN + 5];int bin_search(LL x) { int l = 0, r = len; int mid = 0, ans = 0; while(l <= r) { mid = (l + r) >> 1; if(d[mid] >= x) ans = mid, r = mid - 1; else l = mid + 1; } return ans;}void get_LIS(bool c){ len = 0; d[len] = -INF; //初始d[0] == 0的,如果LIS中有0,就会少算一个 if(c == 1) { for(int i = 1; i <= tot; i++) a[i] = tmp[i].y; } else { //求下降时将数组倒过来求最长 for(int i = 1; i <= tot; i++) a[i] = tmp[tot - i + 1].y; } for(int i = 1; i <= tot; i++) { if(a[i] > d[len]) d[++len] = a[i]; else { int pos = bin_search(a[i]); d[pos] = a[i]; } }}//----------------------------------------int main(){ tot = 0; res = 0.0; scanf("%lld %lld %lld %lld", &sx, &sy, &tx, &ty); if(sx > tx) { //让起点在左边 swap(sx, tx); swap(sy, ty); } scanf("%d", &n); for(int i = 1; i <= n; i++) { LL x, y; scanf("%lld %lld", &x, &y); //将在 起点和终点所形成的矩形 中的点给抠出来 if((min(sx, tx) <= x && x <= max(sx, tx)) && (min(sy, ty) <= y && y <= max(sy, ty))) tmp[++tot].x = x, tmp[tot].y = y; } sort(tmp + 1, tmp + tot + 1, cmpx); if(sy > ty) { //取最长下降子序列 get_LIS(0); } else if(sy <= ty) { //取最长上升子序列 get_LIS(1); } int num = min(abs(tx - sx), abs(ty - sy)) + 1; if(len == num) { //肯定会直线经过一个喷泉,其他都是拐角 res = (100.0 * (abs(tx - sx) + abs(ty - sy)) - 20.0 * (LL)len) + (LL)(len - 1) * 5 * PI + 10 * PI; } else { //全是拐角经过 res = (100.0 * (abs(tx - sx) + abs(ty - sy)) - 20.0 * (LL)len) + (LL)len * 5 * PI; } printf("%.15lf\n", res); return 0;}
- AtCoder Grand Contest 019 C
- (AtCoder Grand Contest 019) C
- Atcoder Grand Contest 019
- Atcoder Grand Contest 013C
- AtCoder Grand Contest 017 C
- 【AtCoder】 Grand Contest 018 C
- 题解Atcoder Grand Contest C
- AtCoder Grand Contest 001 C
- AtCoder Grand Contest 019 B
- Atcoder Grand Contest 019 总结
- AtCoder Grand Contest 019 E
- AtCoder Grand Contest 019 F
- AtCoder Grand Contest 010
- AtCoder Grand Contest 011
- AtCoder Grand Contest 018
- AtCoder Grand Contest 018
- AtCoder Grand Contest 010
- AtCoder Grand Contest 008
- python之正则表达式教程(初级)
- 0828 Web知识初了解
- 内存管理--堆
- 搭建Spring boot基本环境-idea
- linux tomcat启动与端口占用查看
- (AtCoder Grand Contest 019) C
- iOS逆向工具--usbmuxd使用
- Python培训机构学员感悟
- http与Socket区别
- Labview通过RS422通讯接口PC与下位机通信
- Swift 项目中可能用到的第三方框架
- idea使用笔记
- Java NIO -基础认知
- JDK源码分析之String(一)