HDU 4717 The Moving Points (三分法)】的更多相关文章

题意:给n个点的坐标的移动方向及速度,问在之后的时间的所有点的最大距离的最小值是多少. 思路:三分.两点距离是下凹函数,它们的max也是下凹函数.可以三分. #include<iostream> #include<algorithm> #include<cstring> #include<cstdio> #include<cstdlib> #include<string> #include<cmath> #include&…
The Moving Points Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 72    Accepted Submission(s): 18 Problem Description There are N points in total. Every point moves in certain direction and cer…
Description There are N points in total. Every point moves in certain direction and certain speed. We want to know at what time that the largest distance between any two points would be minimum. And also, we require you to calculate that minimum dist…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4717 题意:给出n个点的坐标和运动速度(包括方向).求一个时刻t使得该时刻时任意两点距离最大值最小. 思路:每两个点之间的距离随时间的变化是一个开口向上的抛物线.把所有的抛物线画出来.然后每个时刻取最大值.发现这个最大值是单峰函数. struct point { double x,y; void get() { RD(x,y); } point(){} point(double _x,double…
http://acm.hdu.edu.cn/showproblem.php?pid=4717 [题意]: 给N个点,给出N个点的方向和移动速度,求每个时刻N个点中任意两点的最大值中的最小值,以及取最小值的时刻 [题解]: 两个点为例,任意两个点,按照自己的方向移动,一般情况下是,先两点慢慢接近,直到最近距离,然后慢慢远离,后面越来越远,图像画出来有点像抛物线, 这题就是抛物线求最小值,三分:先二分时间,按照斜率确定移动方向,直到移动到抛物线的最低端 注意题目精度,每次最好分1e-5以上,才能保证…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4717 说明下为啥满足三分: 设y=f(x) (x>0)表示任意两个点的距离随时间x的增长,距离y的变化.则f(x)函数单调性有两种:1.先单减,后单增.2.一直单增. 设y=m(x) (x>0)表示随时间x的增长,所有点的最大距离y的变化.即m(x)是所有点对构成的f(x)图像取最上面的部分.则m(x)的单调性也只有两种可能:1.先单减,后单增.2.一直单增. 这个地方的证明可以这样:假如时刻t1…
http://acm.hdu.edu.cn/showproblem.php?pid=4717 大致题意:给出每一个点的坐标以及每一个点移动的速度和方向. 问在那一时刻点集中最远的距离在全部时刻的最远距离中最小. 比赛时一直以为是计算几何,和线段相交什么的有关.赛后队友说这是道三分,细致想了想确实是三分.试着画绘图发现它是一个凸性函数,存在一个最短距离. 然后三分时间就能够了. #include <stdio.h> #include <iostream> #include <m…
题目链接 第一次写三分 三分的基本模板 int SanFen(int l,int r) //找凸点 { ) { //mid为中点,midmid为四等分点 ; ; if( f(mid) > f(midmid) ) r = midmid; else l = mid; } return f(l) > f(r) ? l : r; } 这道题里面任意两点的距离都可以看作是一个凹函数,对任意t对所有凹函数取最大值构成一个新的凹函数,求新函数的最小值 #include<bits/stdc++.h>…
The Moving Points Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 878    Accepted Submission(s): 353 Problem Description There are N points in total. Every point moves in certain direction and c…
题意:坐标系上有n个点,每个点的坐标和移动方向速度告诉你,速度方向都是固定的.然后要求一个时刻,使得这个时刻,这些点中最远的距离最小. 做法:三分法,比赛的时候想不到.考虑两个点,如果它们走出来的路径能在一定时间后相交的话,那么它们之间的距离肯定是先减小后增大,这样其实可以写成一个二次函数(开口朝下),然后考虑所有的点对之间的最远点,就是对所有的二次函数取一个最大值,嗯,好像还是个二次函数,呃,乱想的,想不下去了. 比赛时候想到可能是单调的或者单峰的,现在还是有点想不通,求解答. #define…
The Moving Points Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 710    Accepted Submission(s): 290 Problem Description There are N points in total. Every point moves in certain direction and…
The Moving Points Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 964    Accepted Submission(s): 393 Problem Description There are N points in total. Every point moves in certain direction and c…
The Moving Points Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 612    Accepted Submission(s): 250 Problem Description There are N points in total. Every point moves in certain direction and…
The Moving Points Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2122    Accepted Submission(s): 884 Problem Description There are N points in total. Every point moves in certain direction and…
Codeforce 1311 F. Moving Points 解析(思維.離散化.BIT.前綴和) 今天我們來看看CF1311F 題目連結 題目 略,請直接看原題. 前言 最近寫1900的題目更容易不看題解了,不知道是不是較少人\(AC\)的同難度題目會比較簡單. @copyright petjelinux 版權所有 觀看更多正版原始文章請至petjelinux的blog 想法 首先注意到,如果\(x\)座標上的前後兩點\(x_i,x_j\),\(x_i<x_j\),如果\(v[x_i]>v…
链接:http://acm.hdu.edu.cn/showproblem.php?pid=4717 n个点,给出初始坐标和移动的速度和移动的方向,求在哪一时刻任意两点之间的距离的最大值的最小. 对于最大值的最小问题首先就会想到二分,然而由于两点之间的距离是呈抛物线状,所以三分的方法又浮上脑海,当然二分也可以做,不过思维上更复杂一些 #include<cmath> #include<cstdio> #include<cstring> #include<iostrea…
There are N points in total. Every point moves in certain direction and certain speed. We want to know at what time that the largest distance between any two points would be minimum. And also, we require you to calculate that minimum distance. We gua…
题意 二维空间中有\(n\)个运动的点,每个点有一个初始坐标和速度向量.求出一个时间\(T\),使得此时任意两点之间的最大距离最小.输出\(T\)和最大距离. 题解 模拟退火. 这个题告诉了我,初始步长要够大.这是很重要的. //#include <bits/stdc++.h> #include <cstdio> #include <cmath> #include <ctime> #include <algorithm> #include <…
Description There are N points in total. Every point moves in certain direction and certain speed. We want to know at what time that the largest distance between any two points would be minimum. And also, we require you to calculate that minimum dist…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4717 思路:三分时间求极小值. #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <cmath> using namespace std; const int MAX_N = (300 + 30); const double e…
Problem Description There are N points in total. Every point moves in certain direction and certain speed. We want to know at what time that the largest distance between any two points would be minimum. And also, we require you to calculate that mini…
Clarke and points 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5626 Description Clarke is a patient with multiple personality disorder. One day he turned into a learner of geometric. He did a research on a interesting distance called Manhattan Dis…
Problem Description The famous ACM (Advanced Computer Maker) Company has rented a floor of a building whose shape is in the following figure. The floor has 200 rooms each on the north side and south side along the corridor. Recently the Company made…
很容易想到三分法求解,不过要分别在0-pi,pi-2pi进行三分. 另外也可以直接暴力枚举…… 代码如下: #include<iostream> #include<stdio.h> #include<algorithm> #include<iomanip> #include<cmath> #include<cstring> #include<vector> #define ll __int64 #define pi aco…
Clarke and points Problem Description   The Manhattan Distance between point A(XA,YA) and B(XB,YB) is |XA - XB| + |Xb - YB|;the coordinate of each point is generated by the followed code.Input long long seed;inline long long rand(long long l, long lo…
当时做这道题时一直想退出物理公式来,但是后来推到导数那一部分,由于数学不好,没有推出来那个关于Θ的最值,后来直接暴力了,很明显超时了,忘了三分法的应用,这道题又是典型的三分求最值,是个单峰曲线,下面是代码 #include <stdio.h> #include <math.h> #define PI 3.1415926 int v, h; double f(double i)//推倒物理公式 { *i)/9.8+(sqrt(v*v*1.0*sin(i)*sin(i)+2.0*9.8…
Problem Description Clarke is a patient with multiple personality disorder. One day he turned into a learner of geometric.  He did a research on a interesting distance called Manhattan Distance. The Manhattan Distance between point A(xA,yA) and point…
链接 需要特判一下n=1的时候 精度调太低会超时 #include <iostream> #include<cstdio> #include<cstring> #include<algorithm> #include<stdlib.h> #include<vector> #include<cmath> #include<queue> #include<set> using namespace std…
这道题看了大家都是用三分做的,其实这道题也是可以用二分来做的,就是利用一下他们的单调性. 对于N个点,总共要考虑N(N+1)/2个距离,距离可以用二次函数表示,而且开口都是向上的. 下面具体说一下二分的过程: 令mid=(L+R)/2,求出在mid时刻的最大距离,同时标记这个最大距离所在的二次函数, 这时候需要判断下mid时刻与对称轴之间的位置关系 1.当mid在对称轴右边时,由于开口是向上的,则最大距离往右是递增的,不可能取到更小值,所以令R=mid: 2.同理,当mid在对称轴左边时,由于开…
题目链接 第一次写三分 三分的基本模板 int SanFen(int l,int r) //找凸点 { ) { //mid为中点,midmid为四等分点 ; ; if( f(mid) > f(midmid) ) r = midmid; else l = mid; } return f(l) > f(r) ? l : r; } 这道题里面任意两点的距离都可以看作是一个凹函数,对任意t对所有凹函数取最大值构成一个新的凹函数,求新函数的最小值 #include<bits/stdc++.h>…