아 날로 그 Codeforces Round\#203(Div.2)C.폭탄

14144 단어 codeforces

제목 주소:http://codeforces.com/problemset/problem/350/C
 1 /*  2    :         ,             ,          ,  3  4    +  :sort  ,         5    :      0           ,                6 */  7 #include <cstdio>  8 #include <iostream>  9 #include <algorithm> 10 #include <string> 11 #include <cmath> 12 #include <cstring> 13 #include <map> 14 #include <set> 15 using namespace std; 16 17 const int MAXN = 1e5 + 10; 18 const int INF = 0x3f3f3f3f; 19 struct NODE 20 { 21 int x, y; 22 int ok; 23 int sum; 24 }node[MAXN]; 25 26 bool cmp(NODE a, NODE b) 27 { 28 return a.sum < b.sum; 29 } 30 31 int main(void) //Codeforces Round #203 (Div. 2) C. Bombs 32 { 33 //freopen ("F.in", "r", stdin); 34 35 int n; 36 while (~scanf ("%d", &n)) 37  { 38 int cnt = 0; 39 for (int i=1; i<=n; ++i) 40  { 41 scanf ("%d%d", &node[i].x, &node[i].y); 42 node[i].sum = abs (node[i].x) + abs (node[i].y); 43 //if (node[i].x < 0) node[i].x = -node[i].x; 44 //if (node[i].y < 0) node[i].y = -node[i].y; 45 if (node[i].x == 0 || node[i].y == 0) node[i].ok = 1, cnt++; 46 else node[i].ok = 0; 47  } 48 sort (node+1, node+1+n, cmp); 49 50 printf ("%d
", (n - cnt) * 6 + 4 * cnt); 51 for (int i=1; i<=n; ++i) 52 { 53 if (node[i].ok == 0) 54 { 55 printf ("%d %d %c
", 1, abs (node[i].x), (node[i]. x < 0) ? 'L' : 'R'); 56 printf ("%d %d %c
", 1, abs (node[i].y), (node[i]. y < 0) ? 'D' : 'U'); 57 puts ("2"); 58 printf ("%d %d %c
", 1, abs (node[i].x), (node[i]. x < 0) ? 'R' : 'L'); 59 printf ("%d %d %c
", 1, abs (node[i].y), (node[i]. y < 0) ? 'U' : 'D'); 60 puts ("3"); 61 } 62 else 63 { 64 if (node[i].x == 0) 65 { 66 printf ("%d %d %c
", 1, abs (node[i].y), (node[i]. y < 0) ? 'D' : 'U'); 67 puts ("2"); 68 printf ("%d %d %c
", 1, abs (node[i].y), (node[i]. y < 0) ? 'U' : 'D'); 69 puts ("3"); 70 } 71 else 72 { 73 printf ("%d %d %c
", 1, abs (node[i].x), (node[i]. x < 0) ? 'L' : 'R'); 74 puts ("2"); 75 printf ("%d %d %c
", 1, abs (node[i].x), (node[i]. x < 0) ? 'R' : 'L'); 76 puts ("3"); 77 } 78 } 79 } 80 } 81 82 return 0; 83 }

좋은 웹페이지 즐겨찾기