码迷,mamicode.com
首页 > 其他好文 > 详细

2333

时间:2015-08-19 19:45:36      阅读:107      评论:0      收藏:0      [点我收藏+]

标签:

 1 /************************************************
 2 * Author        :Running_Time
 3 * Created Time  :2015-8-19 15:44:11
 4 * File Name     :G.cpp
 5  ************************************************/
 6 
 7 #include <cstdio>
 8 #include <algorithm>
 9 #include <iostream>
10 #include <sstream>
11 #include <cstring>
12 #include <cmath>
13 #include <string>
14 #include <vector>
15 #include <queue>
16 #include <deque>
17 #include <stack>
18 #include <list>
19 #include <map>
20 #include <set>
21 #include <bitset>
22 #include <cstdlib>
23 #include <ctime>
24 using namespace std;
25 
26 #define lson l, mid, rt << 1
27 #define rson mid + 1, r, rt << 1 | 1
28 typedef long long ll;
29 const int MAXN = 1e2 + 10;
30 const int INF = 0x3f3f3f3f;
31 const int MOD = 1e9 + 7;
32 int a[MAXN][MAXN];
33 
34 int main(void)    {
35     int n, m;
36     while (scanf ("%d%d", &n, &m) == 2) {
37         int sum = 0;    int mn = INF, x = 0, y = 0;
38         for (int i=1; i<=n; ++i)    {
39             for (int j=1; j<=m; ++j)    {
40                 scanf ("%d", &a[i][j]); sum += a[i][j];
41                 if (mn > a[i][j] && (i + j) & 1)    {
42                     mn = a[i][j];   x = i, y = j;
43                 }
44             }
45         }
46         if (n & 1 || m & 1) {
47             printf ("%d\n", sum);
48             if (n & 1)  {
49                 bool flag = false;
50                 for (int i=1; i<=n; ++i) {
51                     for (int j=1; j<=m; ++j)    {
52                         printf ("%c", flag ? L : R);
53                     }
54                     flag = !flag;
55                     if (i < n)  printf ("%c", D);
56                 }
57             }
58             else    {
59                 bool flag = false;
60                 for (int i=1; i<=m; ++i) {
61                     for (int j=1; j<=n; ++j)    {
62                         printf ("%c", flag ? U : D);
63                     }
64                     flag = !flag;
65                     if (i < m)  printf ("%c", R);
66                 }
67             }
68         }
69         else    {
70             //
71         }
72         puts ("");
73     }
74 
75     return 0;
76 }

 



/************************************************ * Author :Running_Time * Created Time :2015-8-19 15:44:11 * File Name :G.cpp ************************************************/ #include #include #include #include #include #include #include #include #include #include #include #include #include

#include #include #include #include using namespace std; #define lson l, mid, rt << 1 #define rson mid + 1, r, rt << 1 | 1 typedef long long ll; const int MAXN = 1e2 + 10; const int INF = 0x3f3f3f3f; const int MOD = 1e9 + 7; int a[MAXN][MAXN]; int main(void) { int n, m; while (scanf ("%d%d", &n, &m) == 2) { int sum = 0; int mn = INF, x = 0, y = 0; for (int i=1; i<=n; ++i) { for (int j=1; j<=m; ++j) { scanf ("%d", &a[i][j]); sum += a[i][j]; if (mn > a[i][j] && (i + j) & 1) { mn = a[i][j]; x = i, y = j; } } } if (n & 1 || m & 1) { printf ("%d\n", sum); if (n & 1) { bool flag = false; for (int i=1; i<=n; ++i) { for (int j=1; j<=m; ++j) { printf ("%c", flag ? ‘L‘ : ‘R‘); } flag = !flag; if (i < n) printf ("%c", ‘D‘); } } else { bool flag = false; for (int i=1; i<=m; ++i) { for (int j=1; j<=n; ++j) { printf ("%c", flag ? ‘U‘ : ‘D‘); } flag = !flag; if (i < m) printf ("%c", ‘R‘); } } } else { // } puts (""); } return 0; }

2333

标签:

原文地址:http://www.cnblogs.com/Running-Time/p/4742764.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!