cf C. Bombs
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的更多相关文章
- 题解-Bombs
题解-Bombs 前置知识: 线段树 \(\color{orange}{\texttt{Bombs on luogu}}\) / \(\color{orange}{\texttt{Bombs on C ...
- 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 ...
- cf之路,1,Codeforces Round #345 (Div. 2)
cf之路,1,Codeforces Round #345 (Div. 2) ps:昨天第一次参加cf比赛,比赛之前为了熟悉下cf比赛题目的难度.所以做了round#345连试试水的深浅..... ...
- cf Round 613
A.Peter and Snow Blower(计算几何) 给定一个点和一个多边形,求出这个多边形绕这个点旋转一圈后形成的面积.保证这个点不在多边形内. 画个图能明白 这个图形是一个圆环,那么就是这个 ...
- ARC下OC对象和CF对象之间的桥接(bridge)
在开发iOS应用程序时我们有时会用到Core Foundation对象简称CF,例如Core Graphics.Core Text,并且我们可能需要将CF对象和OC对象进行互相转化,我们知道,ARC环 ...
- [Recommendation System] 推荐系统之协同过滤(CF)算法详解和实现
1 集体智慧和协同过滤 1.1 什么是集体智慧(社会计算)? 集体智慧 (Collective Intelligence) 并不是 Web2.0 时代特有的,只是在 Web2.0 时代,大家在 Web ...
- 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 ...
- 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 ...
- CF #376 (Div. 2) C. dfs
1.CF #376 (Div. 2) C. Socks dfs 2.题意:给袜子上色,使n天左右脚袜子都同样颜色. 3.总结:一开始用链表存图,一直TLE test 6 (1)如果需 ...
随机推荐
- http://wiki.apache.org/tomcat/HowTo
http://wiki.apache.org/tomcat/HowTo Contents Meta How do I add a question to this page? How do I con ...
- BZOJ1672: [Usaco2005 Dec]Cleaning Shifts 清理牛棚
1672: [Usaco2005 Dec]Cleaning Shifts 清理牛棚 Time Limit: 5 Sec Memory Limit: 64 MBSubmit: 414 Solved: ...
- centerOS安装chkrootkit
Chkrootkit是一个在本地系统检查rootkit痕迹的工具,它是检查系统二进制文件是否被rootkit病毒修改的一个shell脚本. (1)centerOS安装chkrootkit 安装gcc编 ...
- 第28讲 UI组件之 ListView和ArrayAdapter
第28讲 UI组件之 ListView和ArrayAdapter 1. Adapter 适配器 Adapter是连接后端数据和前端显示的适配器接口,是数据和UI(View)之间一个重要的纽带.在常见的 ...
- java 字符串为空问题
java 字符串为空问题 String testStr = null; System.out.println(testStr); if (testStr == null) { System.out.p ...
- MVC 区域模块
mvc4.0新增的area区域机制,可以协助你在架构较为大型的项目,让独立性较高的部分功能独立成一个MVC子网站,以降低网站与网站之间的耦合性,也可以通过area的切割,让多人同时开发同一个项目时候, ...
- <Win32_6>程序员求爱的创意程序^_^
作为程序员,我们时常被外界误认为很闷.不浪漫.没创意……等等这一类人,这让我们实在有些感伤啊,我得为程序员呐喊一声: 我们也能可以欢快.浪漫.有创意…… 朋友,你向女生表白过吗? …… 这个问题有点儿 ...
- HDU 2845 Beans (DP)
Problem Description Bean-eating is an interesting game, everyone owns an M*N matrix, which is filled ...
- JavaScripts学习日记——ECMAscript
1.Function对象 Function是一个很特殊的对象,特殊在该对象就像java中的方法一样,可以运行,可以传参数. 三种定义function对象的方法: 1.function fun1(a,b ...
- Linux 运维笔记
#配置静态地址网卡DEVICE="eth0"BOOTPROTO=staticHWADDR="00:0C:29:DC:EA:F7"NM_CONTROLLED=&q ...