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 ...
随机推荐
- ScrollView match_parent不起作用
昨天在项目中遇到一个以前没遇到过的问题,就是ScrollView的match_parent不起作用了.所以记录一下 开始的时候我的布局是: <ScrollView android:layout_ ...
- python自带的调试器
python是自带调试器的. 比如你写了一个python程序,名叫test.py. 你想调试一下这个程序,你可以执行 python -m pdb test.py,就会进入test.py的调试. 想查看 ...
- HttpWebRequest post 提交 C#的WebBrowser操作frame如此简单 WebClient 提交
//http://www.cnblogs.com/cgli/archive/2011/04/09/2010497.html System.Net.ServicePointManager.Expect1 ...
- [C++]指针与多级指针(图解)
声明:如需引用或者摘抄本博文源码或者其文章的,请在显著处注明,来源于本博文/作者,以示尊重劳动成果,助力开源精神.也欢迎大家一起探讨,交流,以共同进步- 0.0 演示: /* @author:John ...
- luogu P4289 [HAOI2008]移动玩具
传送门 这道题可以二进制记录状态搜索 也可以做以下考虑 若一个棋子要移动到另一个位置上去,则步数为两点的曼哈顿距离(横坐标差的绝对值+纵坐标差的绝对值),因为假设路径上有其他的棋子,可以通过移动其他棋 ...
- 第4月第10天 iOS项目 mvc
1. 一个uiviewcontroller发送网络请求,解析数据后放在数组里.如果是多个网络请求,就要多个成员变量存储.那是不是可以单独出一个model来解析数据,存储数据呢. 如果有一个Reques ...
- HTML5 CSS JavaScript在网页中扮演的角色
HTML (content layer) CSS (presentation layer) JavaScript (Interactive layer) 参考链接: [1] https://www.y ...
- mongodb系列~ mongodb慢语句(3)
简介: 关于mongodb慢日志是如何收集 一 mongodb慢日志的开启 1 直接设置参数,不重启服务:db.setProfilingLevel(1) 2 添加启动参数,重启服务:添加profile ...
- Android测试技能树
Android 基础知识 Android 的体系结构 apk 的组成结构 adb 命令的使用 Android 的四大组件 Activity 的生命周期 … 测试/开发环境的准备 JDK 安装 SDK ...
- maven插件的使用
maven插件官网: https://maven.apache.org/plugins/index.html 1.JDK插件的使用 <build> <plugins> < ...