#include using namespace std; struct Timer { using Clock = chrono::high_resolution_clock; chrono::time_point st{Clock::now()}; double elapsed() const { return chrono::duration(Clock::now() - st).count(); } }; constexpr int N = 10; constexpr int T = 1000; constexpr int choose = 6; constexpr int seed = 123456789; constexpr double TL = 1.95; int main() { int n_in, t_in; if (!(cin >> n_in >> t_in)) return 0; vector> A(N, vector(N, 0)); for (int i = 0; i < N; ++i) { for (int j = 0; j < N; ++j) { cin >> A[i][j]; } } Timer timer; mt19937 rng(seed); uniform_int_distribution dist(0, N*N - 1); int best_score = -1; vector best_combination, best_candidate_vals; while (timer.elapsed() < TL) { vector combination, candidate_vals; while (combination.size() < choose) { int idx = dist(rng); if (find(combination.begin(), combination.end(), idx) == combination.end()) { combination.emplace_back(idx); } } candidate_vals.emplace_back(0); for (int i = 0; i < choose; ++i) { candidate_vals.emplace_back(A[combination[i] / N][combination[i] % N] ^ candidate_vals.back()); } int score = 0; for (int i = 0; i < N; i++) { for (int j = 0; j < N; j++) { int val = A[i][j]; for (int v : candidate_vals) { val = max(val, A[i][j] ^ v); } score += val; } } if (score > best_score) { best_score = score; best_combination = combination; best_candidate_vals = candidate_vals; } } cerr << "Best score: " << best_score << endl; vector> result(N, vector(N, 0)); for (int i = 0; i < N; ++i) { for (int j = 0; j < N; ++j) { int val = -1; int idx = -1; for (int k = 0; k < choose + 1; ++k) { if (val < A[i][j] ^ best_candidate_vals[k]) { val = A[i][j] ^ best_candidate_vals[k]; idx = k; } } result[i][j] = idx; } } vector output; output.reserve(1000); for (int i = 0; i < choose + 1; ++i) { for (int j = 0; j < N; ++j) { for (int k = 0; k < N; ++k) { if (result[j][k] == i && i != 0) { output.emplace_back('W'); } if (k != N-1) { output.emplace_back(j % 2 ? 'L' : 'R'); } } if (j != N-1) { output.emplace_back('D'); } } if (i == choose) break; int x = best_combination[i] / N; int y = best_combination[i] % N; for (int j = x; j < N-1; ++j) { output.emplace_back('U'); } for (int j = 0; j < y; ++j) { output.emplace_back('R'); } output.emplace_back('C'); for (int j = 0; j < x; ++j) { output.emplace_back('U'); } for (int j = 0; j < y; ++j) { output.emplace_back('L'); } } for (char c : output) { cout << c << endl; } }