模拟 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 ...
随机推荐
- Zookeeper Invalid config, exiting abnormally
Zookeeper Invalid config, exiting abnormally 出现 Invalid config, exiting abnormally 的情况可能有3个: 是否开 ...
- PHP导出数据到CSV文件函数/方法
如果不清楚什么是CSV文件,可看如下文章介绍 CSV格式的是什么文件?CSV是什么的缩写? /** * 导出数据到CSV文件 * @param array $data 数据 * @param arr ...
- [codeforces 528]B. Clique Problem
[codeforces 528]B. Clique Problem 试题描述 The clique problem is one of the most well-known NP-complete ...
- nyoj 8
http://acm.nyist.net/JudgeOnline/problem.php?pid=8 #include<stdio.h> #include<iostream> ...
- neutron 中 flat vlan gre vxlan的区别
In a flat network, everyone shares the same network segment. For example, say 2 tenants are sharing ...
- Minimum Path Sum
Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which ...
- jstl数字转日期
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %> <jsp: ...
- Android Intent不可传递大数据
今天用intent传递一个bitmap,结果一直出错,intent无法执行,原来是intent不能传递大数据导致的,具体是多大,不太清楚,但我传递的bitmap在1m以上.
- 用php计算行列式
因为有课程设计要计算多元一次方程组,所以想编个程序实现,多元一次方程组的计算最系统的方法就是利用克拉默法则求解方程组,所以只需要编写一个类或者方法求出多元一次方程组系数行列式的值和和其他几个行列式,如 ...
- 一个iOS图片选择器的DEMO(实现图片添加,宫格排列,图片长按删除,以及图片替换等功能)
在开发中,经常用到选择多张图片进行上传或作其他处理等等,以下DEMO满足了此功能中的大部分功能,可直接使用到项目中. 主要功能如下: 1,图片九宫格排列(可自动设置) 2,图片长按抖动(仿苹果软件删除 ...