codeforces 576C Points on Plane 相邻两点的欧拉距离
题意:给出n个点,要求排序后,相邻两点的欧拉距离之和小于等于2.5e9
做法:由于0≤ xi, yi ≤ 1e6,所以可以将x<=1000的点分成一份,1000<x<=2000的点分成第二份,以此类推,分成一千份。
然后每一份中的点都按照y单调排序。拿任意一份点做实验,如果从最小的y开始往上走,那么y的贡献最多1e6,那么一千份就总共最多贡献1e9。
最后考虑x的贡献,在某一份点中,从一个点走到另一个点最多贡献1e3,那么这份总共最多贡献1e9,也就是所有点都在这一份里面,那么考虑所有点集,那x总共贡献1e9。如果分散在其它点集中,那么总共贡献大概想想也是1e9。加起来是2e9,必然满足要求。
所以,排个序就可以做了。
#include<map>
#include<string>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<vector>
#include<iostream>
#include<algorithm>
#include<bitset>
#include<climits>
#include<list>
#include<iomanip>
#include<stack>
#include<set>
using namespace std;
struct point
{
int id,x,y;
bool operator <(point a)const
{
return y<a.y;
}
};
vector<point>bx[];
int main()
{
int n;
scanf("%d",&n);
for(int i=;i<=n;i++)
{
point t;
scanf("%d%d",&t.x,&t.y);
t.id=i;
bx[t.x/].push_back(t);
}
bool flag=;
for(int i=;i<=;i++)
{
sort(bx[i].begin(),bx[i].end());
if(bx[i].size())
{
int len=bx[i].size();
if(!flag)
{
for(int j=;j<len;j++)
printf("%d ",bx[i][j].id);
}
else
{
for(int j=len-;j>-;j--)
printf("%d ",bx[i][j].id);
}
flag^=;
}
}
}
codeforces 576C Points on Plane 相邻两点的欧拉距离的更多相关文章
- codeforces 576c// Points on Plane// Codeforces Round #319(Div. 1)
题意:有n个点,找到一个顺序走遍这n个点,并且曼哈顿距离不超过25e8. 由于给的点坐标都在0-1e6之间.将x轴分成1000*1000,即1000长度为1块.将落在同一块的按y排序,编号为奇的块和偶 ...
- Codeforces 576C. Points on Plane(构造)
将点先按x轴排序,把矩形竖着划分成$10^3$个块,每个块内点按y轴排序,然后蛇形走位上去. 这样一个点到下一个点的横坐标最多跨越$10^3$,一共$10^6$个点,总共$10^9$,一个块内最多走$ ...
- CodeForces 577E Points on Plane(莫队思维题)
题目描述 On a plane are nn points ( x_{i}xi , y_{i}yi ) with integer coordinates between 00 and 10^{6} ...
- Please, another Queries on Array?(Codeforces Round #538 (Div. 2)F+线段树+欧拉函数+bitset)
题目链接 传送门 题面 思路 设\(x=\prod\limits_{i=l}^{r}a_i\)=\(\prod\limits_{i=1}^{n}p_i^{c_i}\) 由欧拉函数是积性函数得: \[ ...
- Codeforces Round #454 D. Power Tower (广义欧拉降幂)
D. Power Tower time limit per test 4.5 seconds memory limit per test 256 megabytes input standard in ...
- Codeforces Round #319 (Div. 1) C. Points on Plane 分块
C. Points on Plane Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/576/pro ...
- codeforces 577E E. Points on Plane(构造+分块)
题目链接: E. Points on Plane time limit per test 2 seconds memory limit per test 256 megabytes input sta ...
- 【CodeForces】576 C. Points on Plane
[题目]C. Points on Plane [题意]给定坐标系中n个点的坐标(范围[0,10^6]),求一种 [ 连边形成链后总长度<=2.5*10^9 ] 的方案.n<=10^6. [ ...
- 构造 - Codeforces Round #319 (Div. 1)C. Points on Plane
Points on Plane Problem's Link Mean: 在二维坐标中给定n个点,求一条哈密顿通路. analyse: 一开始忽略了“无需保证路径最短”这个条件,一直在套最短哈密顿通路 ...
随机推荐
- Docker 面试题
Docker 面试题 Docker? Docker是一个容器化平台,它以容器的形式将您的应用程序及其所有依赖项打包在一起,以确保您的应用程序在任何环境中无缝运行. CI(持续集成)服务器的功能是什么? ...
- 【并行计算-CUDA开发】CUDA bank conflict in shared memory
http://hi.baidu.com/pengkuny/item/c8070b388d75d481b611db7a 以前以为 shared memory 是一个万能的 L1 cache,速度很快,只 ...
- js 返回一个数组里面0出现的次数
var num = new Array(10000).fill('').map((item,index) => (index + 1)). 在点号后面补充代码,让num是这个数组中0出现的次数, ...
- superset使用
部署完成后,就可以登陆superset的web页面: http://192.168.56.105:8088 #默认是8080,在配置文件中可以修改 点database可以选择连接不同的数据源,如My ...
- [转帖]Linux 下实践 VxLAN:虚拟机和 Docker 场景
Linux 下实践 VxLAN:虚拟机和 Docker 场景 https://www.cnblogs.com/bakari/p/11264520.html 实践了下 没问题 作者写的很perfect ...
- sqlserver中分页的方式
1.使用top进行: 1.select top 页大小 * from 表名where id not in(select top 页大小*(查询第几页-1) id from 表名 order by id ...
- Codeforces 1148E Earth Wind and Fire
分析 必要条件: ① $\sum_{i=1}^{n} s_i = \sum_{i=1}^{n} t_i$ 预处理: 将 $s, t$ 从小到大排序. 尝试一 首尾匹配.例子 s = 2, 2, 4, ...
- #import "msado15.dll" no_namespace rename("EOF","adoEOF")
引入动态链接库msado15.dll的信息, no_namespace--无命名空间 rename(“EOF”,“adoEOF”)--把文件结束符“EOF”,更换成“adoEOF”
- PAT A1035 Password (20)
AC代码 注意创造函数条件中使用引用 输出语句注意单复数 #include <cstdio> #include <cstring> #include <iostream& ...
- Rsync快速入门实例(转)
三种主要数据传输方式 单主机本地目录间数据传输(类似cp) Local: rsync [OPTION...] SRC... [DEST] 借助rcp,ssh等通道来传输数据(类似scp) Access ...