#ifndef hari64 #include // #pragma GCC target("avx2") // #pragma GCC optimize("O3") // #pragma GCC optimize("unroll-loops") #define debug(...) #else #include "viewer.hpp" #define debug(...) viewer::_debug(__LINE__, #__VA_ARGS__, __VA_ARGS__) #endif // clang-format off using namespace std;constexpr int INF=1001001001;constexpr long long INFll=1001001001001001001; templatebool chmax(T&a,const T&b){return abool chmin(T&a,const T&b){return a>b?a=b,1:0;} // clang-format on constexpr int DY[4] = {-1, 1, 0, 0}; constexpr int DX[4] = {0, 0, -1, 1}; constexpr char UDLR[4] = {'U', 'D', 'L', 'R'}; vector> XYs = {{0, 0}}; vector hist; string ans; int T; void dfs(int t, int x, int y) { if (!ans.empty()) return; if (t == T + 100) { ans = ""; for (auto& i : hist) ans += UDLR[i]; return; } int ghostT = 4 * (t / 4 - 1); int ghostX = ghostT < 0 ? -1 : XYs[ghostT].first; int ghostY = ghostT < 0 ? -1 : XYs[ghostT].second; if (x == ghostX || y == ghostY) return; for (int k = 0; k < 4; k++) { int nx = x + DX[k]; int ny = y + DY[k]; if (!(0 <= nx && nx < 5 && 0 <= ny && ny < 5)) continue; if (nx == ghostX || ny == ghostY) continue; hist.push_back(k); XYs.emplace_back(nx, ny); dfs(t + 1, nx, ny); hist.pop_back(); XYs.pop_back(); } } int main() { cin.tie(0); ios::sync_with_stdio(false); // T = 1000; // dfs(0, 0, 0); // cout << ans << endl; /** Result: * DU * DRDUDRDDRRUDULUUDLUULLDU * DRDUDRDDRRUDULUUDLUULLDU * DRDUDRDDRRUDULUUDLUULLDU * DRDUDRDDRRUDULUUDLUULLDU * ... */ cin >> T; // dfs(0, 0, 0); // cout << string(ans.begin(), ans.begin() + T) << endl; string strAns = "DU"; while (int(strAns.size()) < T) { strAns += "DRDUDRDDRRUDULUUDLUULLDU"; } cout << string(strAns.begin(), strAns.begin() + T) << endl; return 0; }