模拟 Codeforces Round #203 (Div. 2) C. Bombs
题目地址:http://codeforces.com/problemset/problem/350/C
/*
题意:机器人上下左右走路,把其他的机器人都干掉要几步,好吧我其实没读懂题目,
看着样例猜出来的,这题也蛮水的
模拟+贪心:sort一下,从最近的开始走
注意:坐标有一个为0的比普通的少一半的步骤,每次干掉一个要返回原来的位置
*/
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <map>
#include <set>
using namespace std; const int MAXN = 1e5 + ;
const int INF = 0x3f3f3f3f;
struct NODE
{
int x, y;
int ok;
int sum;
}node[MAXN]; bool cmp(NODE a, NODE b)
{
return a.sum < b.sum;
} int main(void) //Codeforces Round #203 (Div. 2) C. Bombs
{
//freopen ("F.in", "r", stdin); int n;
while (~scanf ("%d", &n))
{
int cnt = ;
for (int i=; i<=n; ++i)
{
scanf ("%d%d", &node[i].x, &node[i].y);
node[i].sum = abs (node[i].x) + abs (node[i].y);
//if (node[i].x < 0) node[i].x = -node[i].x;
//if (node[i].y < 0) node[i].y = -node[i].y;
if (node[i].x == || node[i].y == ) node[i].ok = , cnt++;
else node[i].ok = ;
}
sort (node+, node++n, cmp); printf ("%d\n", (n - cnt) * + * cnt);
for (int i=; i<=n; ++i)
{
if (node[i].ok == )
{
printf ("%d %d %c\n", , abs (node[i].x), (node[i]. x < ) ? 'L' : 'R');
printf ("%d %d %c\n", , abs (node[i].y), (node[i]. y < ) ? 'D' : 'U');
puts ("");
printf ("%d %d %c\n", , abs (node[i].x), (node[i]. x < ) ? 'R' : 'L');
printf ("%d %d %c\n", , abs (node[i].y), (node[i]. y < ) ? 'U' : 'D');
puts ("");
}
else
{
if (node[i].x == )
{
printf ("%d %d %c\n", , abs (node[i].y), (node[i]. y < ) ? 'D' : 'U');
puts ("");
printf ("%d %d %c\n", , abs (node[i].y), (node[i]. y < ) ? 'U' : 'D');
puts ("");
}
else
{
printf ("%d %d %c\n", , abs (node[i].x), (node[i]. x < ) ? 'L' : 'R');
puts ("");
printf ("%d %d %c\n", , abs (node[i].x), (node[i]. x < ) ? 'R' : 'L');
puts ("");
}
}
}
} return ;
}
模拟 Codeforces Round #203 (Div. 2) C. Bombs的更多相关文章
- 贪心+模拟 Codeforces Round #288 (Div. 2) C. Anya and Ghosts
题目传送门 /* 贪心 + 模拟:首先,如果蜡烛的燃烧时间小于最少需要点燃的蜡烛数一定是-1(蜡烛是1秒点一支), num[g[i]]记录每个鬼访问时已点燃的蜡烛数,若不够,tmp为还需要的蜡烛数, ...
- 模拟 Codeforces Round #249 (Div. 2) C. Cardiogram
题目地址:http://codeforces.com/contest/435/problem/C /* 题意:给一组公式,一组数据,计算得到一系列的坐标点,画出折线图:) 模拟题:蛮恶心的,不过也简单 ...
- 模拟 Codeforces Round #297 (Div. 2) A. Vitaliy and Pie
题目传送门 /* 模拟:这就是一道模拟水题,看到标签是贪心,还以为错了呢 题目倒是很长:) */ #include <cstdio> #include <algorithm> ...
- queue+模拟 Codeforces Round #304 (Div. 2) C. Soldier and Cards
题目传送门 /* 题意:两堆牌,每次拿出上面的牌做比较,大的一方收走两张牌,直到一方没有牌 queue容器:模拟上述过程,当次数达到最大值时判断为-1 */ #include <cstdio&g ...
- 模拟 Codeforces Round #288 (Div. 2) A. Pasha and Pixels
题目传送门 /* 模拟水题:给定n*m的空白方格,k次涂色,将(x,y)处的涂成黑色,判断第几次能形成2*2的黑色方格,若不能,输出0 很挫的判断四个方向是否OK */ #include <cs ...
- Codeforces Round #203 (Div. 2)B Resort
Resort Time Limit:2000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64u Submit Stat ...
- Codeforces Round #203 (Div. 2)
非常幸运..第三题,有个地方没想清楚,枚举一下就行了..x to n,这个x没考虑好,跪了...傻傻的lock了代码,通过hack进了DIV1,5-2 . 第一次进入DIV1,记录一下. 不知不觉,已 ...
- Codeforces Round #203 (Div. 2) A.TL
#include <iostream> #include <algorithm> using namespace std; int main(){ int n,m; cin & ...
- Codeforces Round #367 (Div. 2) B. Interesting drink (模拟)
Interesting drink 题目链接: http://codeforces.com/contest/706/problem/B Description Vasiliy likes to res ...
随机推荐
- zstu.4019.排队购票(多维dp)
排队购票 Time Limit: 1 Sec Memory Limit: 64 MB Submit: 1264 Solved: 808 Description 一常球赛开始前,售票工作正在进行中. ...
- python网络编程之最简单的单工通信
tcp_server.py from socket import * server = socket(AF_INET, SOCK_STREAM) server.bind(('',12345)) ser ...
- 新的开始---cocos2d
今天是一个新的开始,cocos2d的环境搭配好了,并且打包案桌apk的环境也搭配好了,安卓的这个搭配环境还是出了一点问题,前面弄了两个晚上(11-12.30)没弄出来,中间好几天都没有去弄,今天光棍节 ...
- PHPStorm+Wamp+Xdebug+Windows7调试代码
Wamp 集成环境 PHPStorm+Xdebug 调试代码 2013.04.16 花了两个小时时间终于 , 配置成功了 ! 我的开发环境如下 , 其它环境也可以参考我的配置 开发环境 : Windo ...
- DCMTK3.6.0(MD支持库)安装说明
一.运行环境:WIN7 32bit + VisualStudio2008 + dcmtk3.6.0 + Cmake2.8.8 或者 WIN7 64bit 二.准备工作: 1)MD/MT的知识储备: / ...
- HDOJ 1878 欧拉回路 nyoj 42一笔画问题
#include<cstdio> #include<cstring> ]; int find(int x) { if(visited[x]!=x) return find(vi ...
- Ubuntu14.04server开放rootssh登录权限
刚安装了Ubuntu 14.04 server的虚拟机,普通帐号可以远程登录,但是root不行,输入密码后一直报错: permission denied 最后发现ssh的配置(/etc/ssh/ssh ...
- 【SpringMVC】SpringMVC系列3之@PathVariable映射URL占位符参数
3.@PathVariable映射URL占位符参数 3.1.概述 带占位符的 URL 是 Spring3.0 新增的功能,该功能在SpringMVC 向 REST 目标挺进发展过程中具有里程碑的意义. ...
- 项目总结(二)--- CocoaPods的简单介绍与使用
先谈下,我们为什么要使用CocoaPods,它能为我们做什么吧. 所有开发过iOS应用的小伙伴们都知道,在整个项目中,第三方库的引用必不可少(特别感谢那些优秀第三方开源库的作者,给我们提供了多大的便捷 ...
- 【读书笔记】读《JavaScript设计模式》之观察者模式
一.定义 在事件驱动的环境中,比如浏览器这种持续寻求用户关注的环境中,观察者模式(又名发布者-订阅者(publisher-subscripber)模式)是一种管理人与其任务之间的关系(确切地讲,是对象 ...