题目大意:在一个平面里有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的更多相关文章

  1. 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 ...

  2. 构造 - Codeforces Round #319 (Div. 1)C. Points on Plane

    Points on Plane Problem's Link Mean: 在二维坐标中给定n个点,求一条哈密顿通路. analyse: 一开始忽略了“无需保证路径最短”这个条件,一直在套最短哈密顿通路 ...

  3. Codeforces Round #319 (Div. 1)C. Points on Plane 分块思想

                                                                              C. Points on Plane On a pl ...

  4. 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 ...

  5. Codeforces Round 319 # div.1 & 2 解题报告

    Div. 2 Multiplication Table (577A) 题意: 给定n行n列的方阵,第i行第j列的数就是i*j,问有多少个格子上的数恰为x. 1<=n<=10^5, 1< ...

  6. codeforces 576c// Points on Plane// Codeforces Round #319(Div. 1)

    题意:有n个点,找到一个顺序走遍这n个点,并且曼哈顿距离不超过25e8. 由于给的点坐标都在0-1e6之间.将x轴分成1000*1000,即1000长度为1块.将落在同一块的按y排序,编号为奇的块和偶 ...

  7. 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 ...

  8. 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 ...

  9. 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 ...

随机推荐

  1. <algorithm>里的sort函数对结构体排序

    题目描述 每天第一个到机房的人要把门打开,最后一个离开的人要把门关好.现有一堆杂乱的机房签到.签离记录,请根据记录找出当天开门和关门的人. 输入描述: 每天的记录在第一行给出记录的条目数M (M &g ...

  2. The android command is deprecated

    新版的SDK tools中的android命令已经不支持 android create project,用起来很不顺手. The "android" command is depr ...

  3. 汕头市队赛 SRM 07 D 天才麻将少女kpm

    这道题放了很久还是回来补了 D 天才麻将少女KPM SRM 07 背景&&描述 天才麻将少女KPM立志要在日麻界闯出一番名堂.     KPM上周叒打了n场麻将,但她这次又没控分,而且 ...

  4. Java SE之字符串常量池

    Reference Document: 什么是字符串常量池?   http://www.importnew.com/10756.html[Recommend] Java常量池理解与总结   http: ...

  5. POJ1751 Highways【最小生成树】

    题意: 给你N个城市的坐标,城市之间存在公路,但是由于其中一些道路损坏了,需要维修,维修的费用与公路长成正比(公路是直的). 但现有M条公路是完整的,不需要维修,下面有M行,表示不需要维修的道路两端的 ...

  6. 第16月第17天 contentMode

    1. self.contentMode = UIViewContentModeScaleAspectFill; self.clipsToBounds = YES; http://blog.csdn.n ...

  7. 变量,id()

    >>> a = 1 >>> print id(a) 2870961640 >>> b = a >>> print id(b) 2 ...

  8. Java中ArrayList循环遍历并删除元素的陷阱

    ava中的ArrayList循环遍历并且删除元素时经常不小心掉坑里,昨天又碰到了,感觉有必要单独写篇文章记一下. 先写个测试代码: import java.util.ArrayList; public ...

  9. 分布式系列 - dubbo服务telnet命令【转】

    dubbo服务发布之后,我们可以利用telnet命令进行调试.管理.Dubbo2.0.5以上版本服务提供端口支持telnet命令,下面我以通过实例抛砖引玉一下: 1.连接服务 测试对应IP和端口下的d ...

  10. git操作之冲突解决

    应用场景,任哥,我两个人共同修改了git项目上的一个文件.zsh命令行模式 准备工作 简写命令解释 gl=git pullgp=git pushgst=git statusgcmsg=git comm ...