#include #include #include #include #include #include #include #include #include #include #include #include #include #define debug_value(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << #x << "=" << x << endl; #define debug(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << x << endl; template inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } using namespace std; typedef long long ll; template vector> vec2d(int n, int m, T v){ return vector>(n, vector(m, v)); } template vector>> vec3d(int n, int m, int k, T v){ return vector>>(n, vector>(m, vector(k, v))); } template void print_vector(vector v, char delimiter=' '){ if(v.empty()) { cout << endl; return; } for(int i = 0; i+1 < v.size(); i++) cout << v[i] << delimiter; cout << v.back() << endl; } using P = pair; using T = tuple; int dx[] = {1, -1, 0, 0}; int dy[] = {0, 0, 1, -1}; int main(){ ios::sync_with_stdio(false); cin.tie(0); cout << setprecision(10) << fixed; int h, w, k, l, r; cin >> h >> w >> k >> l >> r; l--; vector s(h); for(int i = 0; i < h; i++) cin >> s[i]; auto fx = [&](int i, int j){ if(i-1 >= 0 && i+1 < h){ if(s[i-1][j] == '.' && s[i][j] == '.' && s[i+1][j] == '.') return true; } return false; }; auto fy = [&](int i, int j){ if(j-1 >= 0 && j+1 < w){ if(s[i][j-1] == '.' && s[i][j] == '.' && s[i][j+1] == '.') return true; } return false; }; auto f = [&](int i, int j){ return fx(i, j) || fy(i, j); }; if(k < h+w-2){ cout << "No" << endl; return 0; } if(r%2 != l%2){ cout << "No" << endl; return 0; } if((h+w-2) != k-(r-l)){ cout << "No" << endl; return 0; } auto pre = vec3d(h, w, 2, T(-1, -1, -1)); auto ok = vec3d(h, w, 2, false); ok[0][0][0] = true; for(int i = 0; i < h; i++){ for(int j = 0; j < w; j++){ for(int k = 0; k < 2; k++){ if(!ok[i][j][k]) continue; if(i+1 < h && s[i+1][j] == '.'){ int kk = k; if(f(i+1, j) && i+j+1 == l) kk = 1; ok[i+1][j][kk] = true; pre[i+1][j][kk] = {i, j, k}; } if(j+1 < w){ int kk = k; if(f(i, j+1) && i+j+1 == l) kk = 1; ok[i][j+1][kk] = true; pre[i][j+1][kk] = {i, j, k}; } } } } if(!ok[h-1][w-1][1]){ cout << "No" << endl; return 0; } int extra = k-(h-1)-(w-1); int x = h-1, y = w-1, p = 1; if(!ok[h-1][w-1][1]) p = 0; vector

path = {P(x, y)}; while(true){ auto [xx, yy, pp] = pre[x][y][p]; x = xx; y = yy; p = pp; path.push_back({x, y}); if(x == 0 && y == 0) break; } reverse(path.begin(), path.end()); int len = path.size(); string ans; for(int i = 0; i < len-1; i++){ auto [x, y] = path[i]; auto [xx, yy] = path[i+1]; if(xx == x+1){ ans += 'D'; } if(yy == y+1){ ans += 'R'; } if(ans.size() == l){ if(fx(xx, yy)){ while(extra){ ans += "UD"; extra -= 2; } }else{ assert(fy(xx, yy)); while(extra){ ans += "LR"; extra -= 2; } } } } cout << ans << endl; }