#include #include #include #include #include #include #include #include #include using namespace std; using pii = pair; using pll = pair; const bool LOCAL = false; const bool RAND = 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); } mt19937 rnd(8); uniform_int_distribution<> rng(0, 99); struct Input { int h, p, x; }; vector> inputs(1000); void read_input(int t) { if (LOCAL && RAND) { double mu = 7.5 + 0.15 * t; double sigma = 1.5 + 0.03 * t; for (int i = 0; i < 25; i++) { if (rng(rnd) <= p[i]) { normal_distribution<> hdist(mu, sigma); double h_ = hdist(rnd); int h = max(1, (int)floor(h_)); normal_distribution<> pdist(0.8 * h_, pow(0.1 * h_, 2)); double p_ = pdist(rnd); int p = max(0, (int)floor(p_)); inputs[t].push_back(Input{h, p, i}); } } for (auto &inpu : inputs[t]) { es[inpu.x].push_back(E{inpu.h, inpu.p, inpu.x, t, 0}); } } else { int n; cin >> n; if (n == -1) exit(0); for (int i = 0; i < n; i++) { E e{0}; 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; } vector score_sum(25, 0); vector score_ave(25, 0); vector t_score(25, 0); 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++) { score_sum[j] = 0; score_ave[j] = 0; t_score[j] = 0; 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()); } for (auto &e : es[j]) { score_sum[j] += e.h; } if (es[j].size()) { score_ave[j] = score_sum[j] / es[j].size(); t_score[j] = score_ave[j] * (1. + es[j].size() / 10); } } 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 > 300) { n.power = es[k][j].h; } if (i > 600) { n.power = t_score[k]; } 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); } } if (LOCAL && RAND) { ofstream ofs("Visualizer_for_Windows/input.txt"); ofs << p[0]; for (int i = 1; i < 25; i++) { ofs << " " << p[i]; } ofs << endl; for (int i = 0; i < 1000; i++) { ofs << inputs[i].size() << endl; for (auto &inp : inputs[i]) { ofs << inp.h << " " << inp.p << " " << inp.x << endl; } } } return 0; }