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: 一开始忽略了“无需保证路径最短”这个条件,一直在套最短哈密顿通路 ...
随机推荐
- python-Web-数据库-oracle
1.oracle体系结构 --------全局数据库,这里指物理磁盘上的数据库(物理结构,一个真实存在的磁盘目录),一般一台oracle服务器有1个全局数据库,文件占1G多.oracle允许一台 -- ...
- 写linux脚本你怎么能不知道位置参数!?
在写shell脚本的时候,我们经常会手动设置参数,然后对我们的输入的这些参数进行处理和分析,那么这个东东到底值怎么使用的呢? 1.$n $0代表命令本身,$1-9代表接受的第1-9个参数,10以上需要 ...
- LeetCode.1185-一周中的星期几(Day of the Week)
这是小川的第415次更新,第448篇原创 看题和准备 今天介绍的是LeetCode算法题中Easy级别的第266题(顺位题号是1185).给定日期,返回该日期的星期几.输入为三个整数,分别代表日,月和 ...
- 软件测试第2周个人作业:WordCount编码测试
一.Github地址 https://github.com/zhouyubei/WordCount 二.PSP表格 PSP2.1 PSP阶段 预估耗时 (分钟) 实际耗时 (分钟) Planning ...
- jdk1.8 -- 方法推导 静态方法、实例方法、构造方法推导
一.静态方法的推导 public class MainTest { public static void main(String[] args) { // 正常情况下我们需要通过写一个consumer ...
- 【Python】【基础知识】【内置常量】
Python的内置常量有: False.True.None.NotImplemented.Ellipsis.__debug__ 由 site 模块添加的常量:quit.exit.copyright.c ...
- Linux就该这么学——初识重定向
重定向的本质(个人理解) 若是输出重定向,则将命令信息写入到指定文件中; 若是输入重定向,表示将对文件执行一些命令,并将命令结果输出到屏幕. 重定向的5种模式 标准覆盖输入重定向/标准追加输入重定向/ ...
- k8s-部署及介绍
Kubernetes主要功能: 数据卷 Pod中容器之间共享数据,可以使用数据卷. 应用程序健康检查 容器内服务可能进程堵塞无法处理请求,可以设置监控检查策略保证应用健壮性. 复制应用程序 ...
- Codeforces 1228E. Another Filling the Grid
传送门 看到 $n=250$ 显然考虑 $n^3$ 的 $dp$ 设 $f[i][j]$ 表示填完前 $i$ 行,目前有 $j$ 列的最小值是 $1$ 的合法方案数 那么对于 $f[i][j]$ ,枚 ...
- mysql创建表空间和用户
创建表空间名 create database 空间名 default character set utf8 collate utf8_bin; 创建用户create user 用户名 identifi ...