模拟 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 ...
随机推荐
- sql 批量更新
利用update和select进行批量更新 UPDATE Table1 SET categoryId =(SELECT Id FROM Table2 WHERE Table1 .Id=Table2.c ...
- 一个1年前的T-SQL问题
还记得年前的一个SQL问题,当时对SQL刚接触,因此绕开了它.用了别的办法.昨天看SQL突然想起了这个问题.百思不得其解,然后去SQL Server技术交流群,也请教了,大神高文佳,何志勇提示我因为先 ...
- HDU 1875 畅通工程再续 (prim最小生成树)
B - 畅通工程再续 Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Submit S ...
- Linux 面试题总结
一. 填空题1. 在Linux系统中,以 (文件) 方式访问设备 .2. Linux内核引导时,从文件 (/etc/fstab) 中读取要加载的文件系统.3. Linux文件系统中每个文件用 (索引节 ...
- easyui-datagrid 两次请求
原因分析及解决方案 html代码中利用class声明了datagrid,导致easyUI解析class代码的时候先解析class声明中的datagrid,这样组件就请求了一次url:然后又调用js初始 ...
- 利用nginx泛域名解析配置二级域名和多域名
利用nginx泛域名解析配置二级域名和多域名 网站的目录结构为 html ├── bbs └── www html为nginx的安装目录下默认的存放源代码的路径. bbs为论坛程序源代码路径 www为 ...
- Unique Binary Search Trees I & II
Given n, how many structurally unique BSTs (binary search trees) that store values 1...n? Example Gi ...
- python在线文档
中文 http://python.usyiyi.cn/--------------------------不完整 http://www.pythondoc.com/pythontutorial27/i ...
- iOS的 context 和Android 中的 canvas
ios 想要绘图,要用到CGContextRef类.最基本的用法是在- (void)drawRect:(CGRect)rect 函数中绘制. Android 中要用到Canvas类.最基本的用法是在 ...
- ubuntu 13.10 amd64安装ia32-libs
很多软件只有32位的,有的依赖32位库还挺严重的:从ubuntu 13.10已经废弃了ia32-libs,但可以使用多架构,安装软件或包apt-get install program:i386.有的还 ...