题目大意:在一个平面里有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. form表单提交onclick和onsubmit

    onsubmit只能表单上使用,提交表单前会触发, onclick是按钮等控件使用, 用来触发点击事件. 在提交表单前,一般都会进行数据验证,可以选择在submit按钮上的onclick中验证,也可以 ...

  2. Java——分页 Servlet + Jsp+Jdbc 有点瑕疵

    1.创建数据库,插入多条数据 2.java连接DB 3.Person类: package com.phome.po; public class Person { private int id; pri ...

  3. POJ1251 Jungle Roads【最小生成树】

    题意: 首先给你一个图,需要你求出最小生成树,首先输入n个节点,用大写字母表示各节点,接着说有几个点和它相连,然后给出节点与节点之间的权值.拿第二个样例举例:比如有3个节点,然后接下来有3-1行表示了 ...

  4. Git查看单个文件修改历史

    1 命令 git log --pretty=oneline  文件名 ➜ admin git:(feature/v1.5.0_20181202_group) git log --pretty=onel ...

  5. Java用System读取系统相关信息、环境变量——(六)

    package Java_Test; public class System1 { public static void main(String[] args) { // TODO Auto-gene ...

  6. Latex 公式居中

    这么简单的功能要是还要加工具包,LaTeX也不用混了~ 公式用\[...\]来写可以达到公式居中效果. 或者在equation环境外加center环境: \begin{center} \begin{e ...

  7. Kaggle 泰坦尼克

    入门kaggle,开始机器学习应用之旅. 参看一些入门的博客,感觉pandas,sklearn需要熟练掌握,同时也学到了一些很有用的tricks,包括数据分析和机器学习的知识点.下面记录一些有趣的数据 ...

  8. ARMV8 datasheet学习笔记2:概述

    1. 前言 本文主要概括的介绍ARMV8体系结构定义了哪些内容,概括的说: ARM体系结构定义了PE的行为,不会定义具体的实现 ARM体系结构也定义了debug体系结构和trace体系结构 ARM体系 ...

  9. Androi:ViewPager

    Android ViewPager控件的使用(基于ViewPager的横向相册)!!!: http://blog.csdn.net/Android_Tutor/article/details/7980 ...

  10. [转]MySQL中函数CONCAT及GROUP_CONCAT

    一.CONCAT()函数 CONCAT()函数用于将多个字符串连接成一个字符串. 使用数据表Info作为示例,其中SELECT id,name FROM info LIMIT 1;的返回结果为 +-- ...