#include #include #include #include #include #include #include #include using namespace std; using pii = pair; using pll = pair; const bool LOCAL = false; long long s = 0; long long score = 0; int ok_count = 0, try_count = 0; int power = 100; int turn = 1000; vector p(25); int x = 12; struct E { int h, p, x, turn; int damage; }; vector> es(25); struct Node { int x, power, turn, hp; char command; }; bool operator<(const Node&l, const Node&r) { return ((double)l.power / l.turn) < ((double)r.power / r.turn); } void read_input(int t) { int n; cin >> n; if (n == -1) exit(0); for (int i = 0; i < n; i++) { E e; e.turn = t; cin >> e.h >> e.p >> e.x; es[e.x].push_back(e); } } void output(char c) { cout << c << endl; if (c == 'S') x = x; else if (c == 'L') x = (x - 1 + 25) % 25; else if (c == 'R') x = (x + 1) % 25; } int main() { if (LOCAL) { for (int i = 0; i < 25; i++) { cin >> p[i]; } } for (int i = 0; i < turn; i++) { for (int j = 0; j < 25; j++) { if (es[j].empty()) continue; if (j == x) { es[j][0].damage += power / 100; if (es[j][0].h <= es[j][0].damage) { power += es[j][0].p; score += es[j][0].h; } } if (i - es[j][0].turn >= 60 || es[j][0].h <= es[j][0].damage) { es[j].erase(es[j].begin()); } } read_input(i); // rx[i] := (x + i) % 25のマスに移動するためのターン数 // lx[i] := (x - i) % 25のマスに移動するためのターン数 vector rx(25, 100), lx(25, 100); rx[0] = lx[0] = 0; for (int i = 1; i < 25; i++) { int r_x = (x + i) % 25; int l_x = (x - i + 25) % 25; if (es[r_x].empty()) { rx[i] = rx[i - 1] + 1; } else { int ey = (i + rx[i - 1] - es[r_x].begin()->turn); if (ey >= 58) rx[i] = rx[i - 1] + 2; else rx[i] = rx[i - 1] + 1; } if (es[l_x].empty()) { lx[i] = lx[i - 1] + 1; } else { int ey = (i + lx[i - 1] - es[l_x].begin()->turn); if (ey >= 58) lx[i] = lx[i - 1] + 2; else lx[i] = lx[i - 1] + 1; } } vector ns; for (int k = 0; k < 25; k++) { int r_x = (k - x + 25) % 25; int l_x = (x - k + 25) % 25; if (es[k].empty()) continue; int j = 0; int min_dist = min(rx[r_x], lx[l_x]); while (min_dist + i - es[k][j].turn <= 0) { j++; if (j >= es[k].size()) break; } if (j >= es[k].size()) continue; int p = power / 100; int def_turn = (es[k][j].h - es[k][j].damage + p - 1) / p; if (i - es[k][j].turn + def_turn + min_dist >= 59) continue; char command = 'S'; if (k != x) { if (rx[r_x] < lx[l_x]) command = 'R'; else command = 'L'; int nx; if (command == 'R') { nx = (x + 1) % 25; } else { nx = (x - 1 + 25) % 25; } if (!es[nx].empty()) { // cout << "# " << i << " " << nx << " " << i - es[nx].begin()->turn << " " << es[nx].begin()->h << " " << es[nx].begin()->p << endl; if (i - es[nx].begin()->turn >= 57) command = 'S'; } } Node n; n.command = command; n.power = es[k][j].p; if (i > 500) { n.power = es[k][j].h; } n.turn = def_turn + min_dist; if (n.turn == 0) n.turn = 1; n.hp = es[k][j].h - es[k][j].damage; n.x = k; ns.push_back(n); } sort(ns.begin(), ns.end()); reverse(ns.begin(), ns.end()); if (ns.empty()) { cout << "# empty" << endl; output('S'); } else { // cout << "# " << i << " " << ns[0].command << " " << x << " " << ns[0].x << " " << ns[0].power << " " << ns[0].hp << " " << ns[0].turn << endl; output(ns[0].command); } } return 0; }