题目地址: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的更多相关文章

  1. 贪心+模拟 Codeforces Round #288 (Div. 2) C. Anya and Ghosts

    题目传送门 /* 贪心 + 模拟:首先,如果蜡烛的燃烧时间小于最少需要点燃的蜡烛数一定是-1(蜡烛是1秒点一支), num[g[i]]记录每个鬼访问时已点燃的蜡烛数,若不够,tmp为还需要的蜡烛数, ...

  2. 模拟 Codeforces Round #249 (Div. 2) C. Cardiogram

    题目地址:http://codeforces.com/contest/435/problem/C /* 题意:给一组公式,一组数据,计算得到一系列的坐标点,画出折线图:) 模拟题:蛮恶心的,不过也简单 ...

  3. 模拟 Codeforces Round #297 (Div. 2) A. Vitaliy and Pie

    题目传送门 /* 模拟:这就是一道模拟水题,看到标签是贪心,还以为错了呢 题目倒是很长:) */ #include <cstdio> #include <algorithm> ...

  4. queue+模拟 Codeforces Round #304 (Div. 2) C. Soldier and Cards

    题目传送门 /* 题意:两堆牌,每次拿出上面的牌做比较,大的一方收走两张牌,直到一方没有牌 queue容器:模拟上述过程,当次数达到最大值时判断为-1 */ #include <cstdio&g ...

  5. 模拟 Codeforces Round #288 (Div. 2) A. Pasha and Pixels

    题目传送门 /* 模拟水题:给定n*m的空白方格,k次涂色,将(x,y)处的涂成黑色,判断第几次能形成2*2的黑色方格,若不能,输出0 很挫的判断四个方向是否OK */ #include <cs ...

  6. Codeforces Round #203 (Div. 2)B Resort

    Resort Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Submit Stat ...

  7. Codeforces Round #203 (Div. 2)

    非常幸运..第三题,有个地方没想清楚,枚举一下就行了..x to n,这个x没考虑好,跪了...傻傻的lock了代码,通过hack进了DIV1,5-2 . 第一次进入DIV1,记录一下. 不知不觉,已 ...

  8. Codeforces Round #203 (Div. 2) A.TL

    #include <iostream> #include <algorithm> using namespace std; int main(){ int n,m; cin & ...

  9. Codeforces Round #367 (Div. 2) B. Interesting drink (模拟)

    Interesting drink 题目链接: http://codeforces.com/contest/706/problem/B Description Vasiliy likes to res ...

随机推荐

  1. (源码)自己写的ScrollView里套漂亮的圆角listview(算是漂亮吧。。。)

    找了相关的资料终于写完了: http://blog.csdn.net/jamin0107/article/details/6973845 和 http://emmet1988.iteye.com/bl ...

  2. 开机提示grub可咋办啊

    导读 GRUB是多启动规范的实现,它允许用户可以在计算机内同时拥有多个操作系统,并在计算机启动时选择希望运行的操作系统.GRUB可用于选择操作系统分区上的不同内核,也可用于向这些内核传递启动参数. 1 ...

  3. [Educational Codeforces Round 16]E. Generate a String

    [Educational Codeforces Round 16]E. Generate a String 试题描述 zscoder wants to generate an input file f ...

  4. php用soap创建webservice

    php提供了一个专门用于soap操作的扩展库,使用该扩展库后 可以直接在php中进行soap操作.下面将介绍soap的基本操作. 一.soap扩展的使用方法 php的soap扩展库通过soap协议实现 ...

  5. make_head,,,pop_head,,,push_head,,,sort_head..

    STL中,有很多的排序函数模板供我们调用,省去我们自己编写一些排序过程的麻烦.本文是一篇关于STL中堆排序的一个介绍. 本文涉及的几个函数如下:make_heap(), push_heap(), po ...

  6. Watering the Fields(irrigation)

    #include <cstdio> #include <algorithm> struct edge{ int f,t,w; } ed[5000000]; int pl,n,c ...

  7. 对于sharepoint 的解决方案的实际说明

    对于sharepoint 的解决方案  实际上就是cab的包 你把***.wsp改为***.cab我们就可以查看这个包中的所有内容了

  8. (转)Sublime Text 2 2.0.2 序列号

    ----- BEGIN LICENSE -----Andrew WeberSingle User LicenseEA7E-855605813A03DD 5E4AD9E6 6C0EEB94 BC9979 ...

  9. 17.把字符串转换成整数[atoi]

    [题目] 把字符串转换成整数,需要考虑字符串有效性. [代码]  C++ Code  123456789101112131415161718192021222324252627282930313233 ...

  10. Servlet之Cookie操作

    Java对cookie的操作比较简单,主要介绍下建立cookie和读取cookie,以及如何设定cookie的生命周期和cookie的路径问题. 1,建立一个无生命周期的cookie,即随着浏览器的关 ...