标签:
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
标签:
原文地址:http://www.cnblogs.com/Running-Time/p/4742764.html