The Moving Points HDU - 4717】的更多相关文章

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 <…
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…
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…
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个点的坐标和运动速度(包括方向).求一个时刻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 n个点,给出初始坐标和移动的速度和移动的方向,求在哪一时刻任意两点之间的距离的最大值的最小. 对于最大值的最小问题首先就会想到二分,然而由于两点之间的距离是呈抛物线状,所以三分的方法又浮上脑海,当然二分也可以做,不过思维上更复杂一些 #include<cmath> #include<cstdio> #include<cstring> #include<iostrea…
http://acm.hdu.edu.cn/showproblem.php?pid=4717 大致题意:给出每一个点的坐标以及每一个点移动的速度和方向. 问在那一时刻点集中最远的距离在全部时刻的最远距离中最小. 比赛时一直以为是计算几何,和线段相交什么的有关.赛后队友说这是道三分,细致想了想确实是三分.试着画绘图发现它是一个凸性函数,存在一个最短距离. 然后三分时间就能够了. #include <stdio.h> #include <iostream> #include <m…
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…
题意:给n个点的坐标的移动方向及速度,问在之后的时间的所有点的最大距离的最小值是多少. 思路:三分.两点距离是下凹函数,它们的max也是下凹函数.可以三分. #include<iostream> #include<algorithm> #include<cstring> #include<cstdio> #include<cstdlib> #include<string> #include<cmath> #include&…
题目链接 第一次写三分 三分的基本模板 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>…
题目链接: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…
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…
链接 需要特判一下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在对称轴左边时,由于开…
题意:坐标系上有n个点,每个点的坐标和移动方向速度告诉你,速度方向都是固定的.然后要求一个时刻,使得这个时刻,这些点中最远的距离最小. 做法:三分法,比赛的时候想不到.考虑两个点,如果它们走出来的路径能在一定时间后相交的话,那么它们之间的距离肯定是先减小后增大,这样其实可以写成一个二次函数(开口朝下),然后考虑所有的点对之间的最远点,就是对所有的二次函数取一个最大值,嗯,好像还是个二次函数,呃,乱想的,想不下去了. 比赛时候想到可能是单调的或者单峰的,现在还是有点想不通,求解答. #define…
题目链接 第一次写三分 三分的基本模板 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>…
Tree2cycle Time Limit: 15000/8000 MS (Java/Others)    Memory Limit: 102400/102400 K (Java/Others)Total Submission(s): 2161    Accepted Submission(s): 508 Problem Description A tree with N nodes and N-1 edges is given. To connect or disconnect one edg…
题意:给定n个点的初始坐标x和速度v(保证n个点的初始坐标互不相同), d(i,j)是第i个和第j个点之间任意某个时刻的最小距离,求出n个点中任意一对点的d(i,j)的总和. 题解:可以理解,两个点中初始坐标较小的点的速度更大时,总有一个时刻后面的点会追上前面的点,d(i,j) =0. 否则,即后面的点的速度 <= 前面的点的速度时,两点之间的距离只会越来越大,d(i,j) = abs(xi - xj) (初始距离). 可以用直线来辅助理解:x = xi + v*t,横轴为t,纵轴为x,若两直线…
\[ \texttt{Preface} \] 赛时,把 " 任意时刻 " 理解成 " 整数时刻 " 了,看起来一脸不可做的亚子,还各种推式子. 话说我为什么觉得 E 比 F 还难. \[ \texttt{Description} \] 一个坐标轴 \(OX\) 上有 \(n\) 个点,第 \(i\) 个点位于整数点 \(x_i\) ,速度为 \(v_i\) . 所有点以恒定的速度移动,在时刻 \(t\) ( \(t\) 可以是非整数),第 \(i\) 个点的坐标可以…
Solution 按 \(x\) 关键字升序排序,依次枚举每个点 考虑对任意 \(x_j < x_i\),那么当 \(v_j \leq v_i\) 时,它们不会相交,且 \(dis\) 就是它们初态的距离 \(x_i-x_j\) 开两个树状数组,以离散化后的 \(v\) 为下标,一个维护个数和,一个维护坐标和 那么每次询问的答案就是 个数和 $\cdot x_i - $ 坐标和 然后把这个点插进去即可 #include <bits/stdc++.h> using namespace st…
https://codeforces.com/contest/1311/problem/F 这是一道线段树类型的题: 可以用权值线段树或者树状数组来解: 所以,我们可以分为两部分,第一部分是计算出到当前点位置,小于等于当前点的速度的个数 ,总的个数乘当前点的速度 减去 小于等于当前点的速度的坐标总值即为答案: #include<bits/stdc++.h> using namespace std; typedef long long ll; ; int b[maxn]; struct node…
第一次写博客 ,请多指教! 翻了翻前面的题解发现都是用树状数组来做,这里更新一个 线段树+离散化的做法: 其实这道题是没有必要用线段树的,树状数组就能够解决.但是个人感觉把线段树用熟了会比树状数组更有优势一点 不多废话  http://codeforces.com/contest/1311/problem/F 题目链接 题意是 给你一堆点的位置和他们运动的速度(可正可负),然后时间无限往后推的情况下问你他们之间所有点的最小距离之和.(不明白自行读题) n的范围是2,200000: 显然单纯的一个…