Codeforces Round #319 (Div. 2) E - Points on Plane
题目大意:在一个平面里有n个点,点坐标的值在1-1e6之间,让你给出一个遍历所有点的顺序,要求每个点走一次,且
曼哈顿距离之和小于25*1e8。
思路:想了一会就有了思路,我们可以把1e6的x,y坐标都分成2000份,每份500,然后这样整个平面就被分成
了2000*2000个区域,然后按区域输出点就行了。
#include<bits/stdc++.h>
using namespace std;
int n;
vector<int> ans[][];
int main()
{
scanf("%d",&n);
for(int i=;i<=n;i++)
{
int x,y; scanf("%d%d",&x,&y);
ans[x/][y/].push_back(i);
}
bool flag=false;
for(int i=;i<=;i++)
{
if(!flag)
{
for(int j=;j<=;j++)
{
for(int k:ans[i][j]) printf("%d ",k);
}
}
else
{
for(int j=;j>=;j--)
{
for(int k:ans[i][j]) printf("%d ",k);
}
}
flag=!flag;
}
return ;
}
Codeforces Round #319 (Div. 2) E - Points on Plane的更多相关文章
- 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 Round #319 (Div. 1)C. Points on Plane
Points on Plane Problem's Link Mean: 在二维坐标中给定n个点,求一条哈密顿通路. analyse: 一开始忽略了“无需保证路径最短”这个条件,一直在套最短哈密顿通路 ...
- Codeforces Round #319 (Div. 1)C. Points on Plane 分块思想
C. Points on Plane On a pl ...
- Codeforces Round #486 (Div. 3) D. Points and Powers of Two
Codeforces Round #486 (Div. 3) D. Points and Powers of Two 题目连接: http://codeforces.com/group/T0ITBvo ...
- Codeforces Round 319 # div.1 & 2 解题报告
Div. 2 Multiplication Table (577A) 题意: 给定n行n列的方阵,第i行第j列的数就是i*j,问有多少个格子上的数恰为x. 1<=n<=10^5, 1< ...
- codeforces 576c// Points on Plane// Codeforces Round #319(Div. 1)
题意:有n个点,找到一个顺序走遍这n个点,并且曼哈顿距离不超过25e8. 由于给的点坐标都在0-1e6之间.将x轴分成1000*1000,即1000长度为1块.将落在同一块的按y排序,编号为奇的块和偶 ...
- Codeforces Round #466 (Div. 2) -A. Points on the line
2018-02-25 http://codeforces.com/contest/940/problem/A A. Points on the line time limit per test 1 s ...
- Codeforces Round #245 (Div. 2) A. Points and Segments (easy) 贪心
A. Points and Segments (easy) Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/con ...
- Codeforces Round #466 (Div. 2) A. Points on the line[数轴上有n个点,问最少去掉多少个点才能使剩下的点的最大距离为不超过k。]
A. Points on the line time limit per test 1 second memory limit per test 256 megabytes input standar ...
随机推荐
- 一、linux IO 编程---内存管理
1.1 进程在虚拟空间中的布局 32位的操作系统虚拟空间的大小为 4GB,即每个进程在系统中分配的虚拟空间大小为4GB.这4GB的大小被分为了两个部分: 内核空间:1GB,内核起的进程 用户空间:3G ...
- 20155220 2016-2017-2 《Java程序设计》第七周学习总结
20155220 2016-2017-2 <Java程序设计>第七周学习总结 教材学习内容总结 Lambda 如果使用JDK8的话,可以使用Lambda特性去除重复的信息. 在只有Lamb ...
- js 将很长的内容进行页面分页显示
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- Servlet3.0的注解自定义原生Listener监听器实战
简介:监听器介绍和Servlet3.0的注解自定义原生Listener监听器实战 自定义Listener(常用的监听器 servletContextListener.httpSessionListen ...
- WebRTC架构和协议栈-zz
为了便于理解,我们来看一个最基本的三角形WebRTC架构(图4).在这个架构中,移动电话用“浏览器M”表示,笔记本电脑用“浏览器L”表示,通过Web服务器将它们连接起来.要建立一个实时媒体通讯,两台设 ...
- adboost方法(转载)
转载链接:http://blog.csdn.net/google19890102/article/details/46376603 一.集成方法(Ensemble Method) 集成方法主要 ...
- ORB feature(O for orientation)
参考链接:http://blog.csdn.net/yang843061497/article/details/38553765 绪论 假如我有2张美女图片,我想确认这2张图片中美女是否是同一个人.这 ...
- GCC制作动态库导出符号表【转】
转自:https://blog.csdn.net/whb_fei/article/details/76974543 版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.cs ...
- mysql caching_sha2_password异常分析
使用navicat连接mysql报错 解决办法: 通过命令行登录mysql后,输入: alter user 'root'@'localhost' IDENTIFIED WITH mysql_nativ ...
- jenkins cobertura单元测试
1.1 Maven 工程 pom.xml 修改 1.2 Build添加插件目标 此时构建项目,会在项目 targer/site/cobertura 目录中生成 html 与 xml ...