Codeforces 1311F Moving Points】的更多相关文章

题目链接 根据题意,d是两个点的最短距离,分析知,假设\(x_i\)<\(x_j\), 若\(v_i\)>\(v_j\),那么d(i,j)一定为0,因为i一定能追上j,否则,d(i,j)就为其初始距离 那我们就转化问题为一个二维偏序问题,求\(x_i\)<\(x_j\)且\(v_i\)<\(v_j\),满足这个条件的每个点对之间的距离 很容易想到定一序,另一序用树状数组维护的统计法,假设现在是\(x_i\),满足上述条件有k个,那么,对\(x_i\)的统计答案为:\(\sum_{j…
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): 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): 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://codeforces.com/contest/1311/problem/F 题目链接 题意是 给你一堆点的位置和他们运动的速度(可正可负),然后时间无限往后推的情况下问你他们之间所有点的最小距离之和.(不明白自行读题) n的范围是2,200000: 显然单纯的一个…
题意:给定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,若两直线…
D. Points Time Limit: 1 Sec  Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/19/problem/D Description Pete and Bob invented a new interesting game. Bob takes a sheet of paper and locates a Cartesian coordinate system on it as follows: point (…
link:http://codeforces.com/contest/347/problem/B 很简单,最多只能交换一次,也就是说,最多会增加两个.可能会增加一个.也可能一个也不增加(此时都是fixed point) #include <cstdio> using namespace std; ]; int main(void) { #ifndef ONLINE_JUDGE freopen("in.txt", "r", stdin); #endif i…
题目链接: E. Points on Plane time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output On a plane are n points (xi, yi) with integer coordinates between 0 and 106. The distance between the two points wi…
题目链接:http://codeforces.com/problemset/problem/347/B 题目意思:给出一个包含n个数的排列a,在排列a中最多只能作一次交换,使得ai = i 这样的匹配达到最多. 作一次交换,最理想的情况是,在原来匹配好的序列中再匹配到两个数:最坏的情况是,即使作怎样的交换,都不可能再找到可以匹配的两个数,也就是说,根本不需要作交换.至于一般情况下,是可以再匹配到一个数的. 我是设了两个数组(分别有n个数):a(用来存储待判断的序列a)和b(依次存储0-n-1个数…
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…
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…
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…
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://codeforces.com/contest/19/problem/D 题意:给出3种操作:1)添加点(x,y),2)删除点(x,y),3)查询离(x,y)最近的右上方的点. 且满足添加的点不重复,删除的点一定存在. 题解:只要以x建树,记录下每个结点最大的y值.每次都更新一下.用线段树查找满足条件的最小的x,然后用一个set[x]来存x点下的y点. 然后用二分查找满足条件的最小的y. #include <iostream> #include <cstring&g…
题目描述: Match Points time limit per test 2 seconds memory limit per test 256 mega bytes input standard input output standard output You are given a set of points x1, , ..., *x**n* Two points iand jcan be matched with each other if the following conditi…
题 OvO http://codeforces.com/contest/871/problem/C ( Codeforces Round #440 (Div. 1, based on Technocup 2018 Elimination Round 2) - C ) 解 问题可以转化为:这些点可以产生的横线与竖线的出现情况 首先,对于二维坐标系中的每一行中,对于每个点,如果右边有点,则从该点向右边这个点(相邻的那个点)连一条边(连一条单向的), 对于每一列中,对于每个点,如果该点下面有点,则向下…
https://codeforces.com/contest/1311/problem/F 这是一道线段树类型的题: 可以用权值线段树或者树状数组来解: 所以,我们可以分为两部分,第一部分是计算出到当前点位置,小于等于当前点的速度的个数 ,总的个数乘当前点的速度 减去 小于等于当前点的速度的坐标总值即为答案: #include<bits/stdc++.h> using namespace std; typedef long long ll; ; int b[maxn]; struct node…
https://codeforces.com/problemset/problem/1000/C 题意: 有n个线段,覆盖[li,ri],最后依次输出覆盖层数为1~n的点的个数. 思路: 区间线段覆盖问题,第一反应树状数组.线段树,看了看数据规模,开不了这么大的空间. 只能用差分了  代码如下: #include <stdio.h> #include <string.h> #include <iostream> #include <string> #incl…
题:https://codeforces.com/contest/1311/problem/F 题意:给定x轴上的点以及他们的速度v,只在x轴上运动,求最小的dis之和,注意,这里的时间是可随意的,比如对于其中一个点 i 来说,只要其他点运动到离自己距离最小即可,而不是同步运动 分析:对于一对点 i 和 j 来说,以点 i 为基准,要是xj<xi,那么只要vj>xi就可以让dis为0,要是xj>xi,,那么只要vj<vi就可以让dis为0,其他情况就俩者不动就能保持dis最小为ab…
B. Cover Points time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output There are n points on the plane, (x1,y1),(x2,y2),-,(xn,yn). You need to place an isosceles triangle with two sides on the coordin…
Codeforces 题目传送门 & 洛谷题目传送门 显然,直接暴力枚举是不可能的. 考虑将点按横纵坐标奇偶性分组,记 \(S_{i,j}=\{t|x_t\equiv i\pmod{2},y_t\equiv j\pmod{2}\}(i,j\in[0,1])\),说白了就是横坐标为偶数.纵坐标为偶数:横坐标为偶数.纵坐标为奇数:横坐标为奇数.纵坐标为偶数:横坐标为奇数.纵坐标为奇数的点集. 然后考虑以下算法: 若 \(S_{0,0},S_{1,1}\) 以及 \(S_{0,1},S_{1,0}\)…
题意:给n个点的坐标的移动方向及速度,问在之后的时间的所有点的最大距离的最小值是多少. 思路:三分.两点距离是下凹函数,它们的max也是下凹函数.可以三分. #include<iostream> #include<algorithm> #include<cstring> #include<cstdio> #include<cstdlib> #include<string> #include<cmath> #include&…
链接 需要特判一下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个点,m个区间,需要给这些点涂上蓝色或者红色,使得每个区间里面的点的红色的点的个数与蓝色的点的个数的差值小于1 唉,题目的标题就标注了一个easy= = 最开始做的时候对点还有区间都排序了,模拟来做,可是错了 后来发现不管区间怎么样,只要红色和蓝色交替涂色, 就一定能满足“使得每个区间里面的点的红色的点的个数与蓝色的点的个数的差值小于1 ”这个条件 有点像上次做的cf交替输出奇数偶数那个A题 #include<iostream> #include<cstdio> #in…
题目链接: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…