http://codeforces.com/contest/350/problem/C

对n个点按曼哈顿距离排序。

 #include <cstdio>
#include <cstring>
#include <algorithm>
#define maxn 100010
using namespace std; struct node
{
int x,y;
int dir;
bool operator <(const node &a)const
{
return (abs(x)+abs(y))<(abs(a.x)+abs(a.y));
}
}p[maxn]; int n; int main()
{
while(scanf("%d",&n)!=EOF)
{
int cnt=;
for(int i=; i<n; i++)
{
scanf("%d%d",&p[i].x,&p[i].y);
if(p[i].x!=&&p[i].y!=) cnt+=;
else cnt+=;
}
sort(p,p+n);
printf("%d\n",cnt);
for(int i=; i<n; i++)
{
if(p[i].x>)
{
printf("1 %d R\n",abs(p[i].x));
if(p[i].y>)
{
printf("1 %d U\n",abs(p[i].y));
}
else if(p[i].y<)
{
printf("1 %d D\n",abs(p[i].y));
}
printf("2\n");
printf("1 %d L\n",abs(p[i].x));
if(p[i].y>)
{
printf("1 %d D\n",abs(p[i].y));
}
else if(p[i].y<)
{
printf("1 %d U\n",abs(p[i].y));
}
printf("3\n");
}
else if(p[i].x<)
{
printf("1 %d L\n",abs(p[i].x));
if(p[i].y>)
{
printf("1 %d U\n",abs(p[i].y));
}
else if(p[i].y<)
{
printf("1 %d D\n",abs(p[i].y));
}
printf("2\n");
printf("1 %d R\n",abs(p[i].x));
if(p[i].y>)
{
printf("1 %d D\n",abs(p[i].y));
}
else if(p[i].y<)
{
printf("1 %d U\n",abs(p[i].y));
}
printf("3\n");
}
else if(p[i].x==)
{
if(p[i].y>) printf("1 %d U\n",abs(p[i].y));
else if(p[i].y<) printf("1 %d D\n",abs(p[i].y));
printf("2\n");
if(p[i].y>) printf("1 %d D\n",abs(p[i].y));
else if(p[i].y<) printf("1 %d U\n",abs(p[i].y));
printf("3\n");
}
}
}
return ;
}

cf C. Bombs的更多相关文章

  1. 题解-Bombs

    题解-Bombs 前置知识: 线段树 \(\color{orange}{\texttt{Bombs on luogu}}\) / \(\color{orange}{\texttt{Bombs on C ...

  2. ORA-00494: enqueue [CF] held for too long (more than 900 seconds) by 'inst 1, osid 5166'

    凌晨收到同事电话,反馈应用程序访问Oracle数据库时报错,当时现场现象确认: 1. 应用程序访问不了数据库,使用SQL Developer测试发现访问不了数据库.报ORA-12570 TNS:pac ...

  3. cf之路,1,Codeforces Round #345 (Div. 2)

     cf之路,1,Codeforces Round #345 (Div. 2) ps:昨天第一次参加cf比赛,比赛之前为了熟悉下cf比赛题目的难度.所以做了round#345连试试水的深浅.....   ...

  4. cf Round 613

    A.Peter and Snow Blower(计算几何) 给定一个点和一个多边形,求出这个多边形绕这个点旋转一圈后形成的面积.保证这个点不在多边形内. 画个图能明白 这个图形是一个圆环,那么就是这个 ...

  5. ARC下OC对象和CF对象之间的桥接(bridge)

    在开发iOS应用程序时我们有时会用到Core Foundation对象简称CF,例如Core Graphics.Core Text,并且我们可能需要将CF对象和OC对象进行互相转化,我们知道,ARC环 ...

  6. [Recommendation System] 推荐系统之协同过滤(CF)算法详解和实现

    1 集体智慧和协同过滤 1.1 什么是集体智慧(社会计算)? 集体智慧 (Collective Intelligence) 并不是 Web2.0 时代特有的,只是在 Web2.0 时代,大家在 Web ...

  7. CF memsql Start[c]UP 2.0 A

    CF memsql Start[c]UP 2.0 A A. Golden System time limit per test 1 second memory limit per test 256 m ...

  8. CF memsql Start[c]UP 2.0 B

    CF memsql Start[c]UP 2.0 B B. Distributed Join time limit per test 1 second memory limit per test 25 ...

  9. CF #376 (Div. 2) C. dfs

    1.CF #376 (Div. 2)    C. Socks       dfs 2.题意:给袜子上色,使n天左右脚袜子都同样颜色. 3.总结:一开始用链表存图,一直TLE test 6 (1)如果需 ...

随机推荐

  1. Linux企业级项目实践之网络爬虫(14)——使用正则表达式抽取HTML正文和URL

    正则表达式,又称正规表示法.常规表示法(英语:Regular Expression,在代码中常简写为regex.regexp或RE),计算机科学的一个概念.正则表达式使用单个字符串来描述.匹配一系列符 ...

  2. Dynamic Binding & Static Binding

    Reference: JavaPoint BeginnerBook What is Binding Connecting a method call to the method body is kno ...

  3. Raid1源代码分析--初始化流程

    初始化流程代码量比较少,也比较简单.主要是run函数.(我阅读的代码的linux内核版本是2.6.32.61) 四.初始化流程分析 run函数顾名思义,很简单这就是在RAID1开始运行时调用,进行一些 ...

  4. windows puppet manifests 文件维护

    初级 puppet windows agent实现简单的msi格式安装包安装及bat文件创建;

  5. js设计模式系列之(一)请节约你的请求-代理模式

    What’s the proxy pattern? 代理模式其实就是将违反单一性原则的类给抽离出来,尽量满足开放和封闭的原则. 相当于一个类的行为只是一种,但是你可以给这个类添加额外的行为.比如: 一 ...

  6. javaDay1 基础知识

    常用dos命令 •d: 回车  盘符切换 •dir(directory):列出当前目录下的文件以及文件夹 •md (make directory) : 创建目录 •rd (remove directo ...

  7. poj 1466 Girls and Boys(二分匹配之最大独立集)

    Description In the second year of the university somebody started a study on the romantic relations ...

  8. CSS3 div水平、垂直居中,IE9以上、Firefox、Chrome均正常

    <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content ...

  9. UVA 10198 Counting

    Counting The Problem Gustavo knows how to count, but he is now learning how write numbers. As he is ...

  10. java 图片 批量 压缩 +所有压缩

    /* oldsrc  : 原图片地址目录 如 'd:/'    newsrc  : 压缩后图片地址目录 如 'e:/'    widthdist,heightdist : 压缩后的宽和高       ...