首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

Codeforces Round #203 (Div. 二) 水果3题

2013-10-03 
Codeforces Round #203 (Div. 2) 水果3题Codeforces Round #203 (Div. 2)这场在最后千钧一发交了一发过了C

Codeforces Round #203 (Div. 2) 水果3题

Codeforces Round #203 (Div. 2)

这场在最后千钧一发交了一发过了C,不然又要掉rating了。。。

B敲了太久了,orz编码能力不足啊~

A - TL

求编程比赛的时限,使得正确答案都能过,错误答案都不能过,且至少有一个正确答案的时间能小于时限的一半。

模拟水题,看题目看了好久。。

代码:

/**  Author:      illuz <iilluzen[at]gmail.com>*  Blog:        http://blog.csdn.net/hcbbt*  File:        c.cpp*  Create Date: 2013-10-02 01:14:06*  Descripton:  c */#include <cstdio>#include <iostream>#include <algorithm>using namespace std;#define rep(i, n) for (int i = 0; i < (n); i++)typedef long long LL;const int MAXN = 100010;struct P {int x, y;int step;} p[MAXN];int n;bool cmp(P a, P b) {return a.step < b.step;}int main() {cin >> n;LL cnt = 0;rep(i, n) {scanf("%d%d", &p[i].x, &p[i].y); p[i].step = abs(p[i].x) + abs(p[i].y);if (p[i].x) cnt+= 2;if (p[i].y) cnt+=2;cnt += 2;}sort (p, p + n, cmp);cout << cnt << endl;rep(i, n) {if (p[i].x > 0)printf("1 %d R\n", p[i].x);else if (p[i].x < 0)printf("1 %d L\n", -p[i].x);if (p[i].y > 0)printf("1 %d U\n", p[i].y);else if (p[i].y < 0)printf("1 %d D\n", -p[i].y);printf("2\n");if (p[i].x > 0)printf("1 %d L\n", p[i].x);else if (p[i].x < 0)printf("1 %d R\n", -p[i].x);if (p[i].y > 0)printf("1 %d D\n", p[i].y);else if (p[i].y < 0)printf("1 %d U\n", -p[i].y);printf("3\n");}return 0;}


热点排行