https://www.lanqiao.cn/problems/602/learning/?page=1&first_category_id=1&second_category_id=3&name=%E8%BF%B7%E5%AE%AB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PII;
typedef vector<long long> VI;
#define rep(i,a,n) for (int i=a;i<=n;i++)
#define per(i,a,n) for (int i=a;i>=n;i--)
#define pb(i) push_back(i)
#define int long long
#define INF 0x3f3f3f3f
#define oz 998244353
#define endl '\n'
#define N 200010
const int mod = 1e9 + 7;
int p[N], si[N];
int find(int x) {
if (x != p[x]) p[x] = find(p[x]);
return p[x];
}
//size[find(b)] += size[find(a)];
//p[find(a)] = find(b);
bool st[35][50];
struct piont {
int x, y;
string road;
f(int a, int b) {
x = a;
y = b;
}
};
char ch[4] = {'D', 'L', 'R', 'U'};
int dx[4][2] = {1, 0, -0, -1, 0, 1, -1, 0};
char s[35][50];
void solve() {
rep(i, 1, 30) {
rep(j, 1, 50) {
cin >> s[i][j];
}
}
queue<piont> q;
q.push({1, 1, ""});
st[1][1] = 0;
while (!q.empty()) {
auto t = q.front();
q.pop();
if (t.x == 30 && t.y == 50) {
cout << t.road << endl;
return ;
}
for (int i = 0; i < 4; i ++) {
int xx = t.x + dx[i][0], yy = t.y + dx[i][1];
if(xx >= 1 && xx <= 30 && yy >= 1 && yy <= 50 && !st[xx][yy] && s[xx][yy] == '0'){
piont qq = {xx, yy, t.road + ch[i]};
st[xx][yy] = 1;
q.push(qq);
}
}
}
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(0), cout.tie(0);
int T = 1;
// cin >> T;
while (T --)
solve();
return 0;
}