#pragma GCC target("avx2") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #include using namespace std; using lint = long long int; using P = pair; using PL = pair; #define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i=i##_begin_;i--) #define REP(i, n) FOR(i,0,n) #define IREP(i, n) IFOR(i,0,n) #define ALL(a) (a).begin(),(a).end() constexpr int MOD = 1000000007; constexpr lint B1 = 1532834020; constexpr lint M1 = 2147482409; constexpr lint B2 = 1388622299; constexpr lint M2 = 2147478017; constexpr int INF = 1e9; void yes(bool expr) {cout << (expr ? "Yes" : "No") << "\n";} templatevoid chmax(T &a, const T &b) { if (avoid chmin(T &a, const T &b) { if (b dx = {-1, -1, 0, 0, 1, 1}; vector dy = {-1, 0, -1, 1, 0, 1}; struct Enemy { int x, y = 59, h, p; }; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); // vector P(25); // REP(i, 25) cin >> P[i]; vector enemy_cnt(25); int enemy_s = 0; vector enemy; int cur_x = 12; int cur_power = 100; FOR(turn, 1, 1001) { cerr << turn << " " << cur_x << " " << cur_power << endl; FOR(i, enemy_s, enemy.size()) { enemy[i].y--; if(enemy[i].y == -1) enemy_s++; } int n; cin >> n; if(n == -1) return 0; REP(i, n) { Enemy e; cin >> e.h >> e.p >> e.x; enemy.push_back(e); } REP(i, n) enemy_cnt[enemy[i].x]++; vector> is_enemy(25, vector(60)); FOR(i, enemy_s, enemy.size()) if(enemy[i].h > 0) is_enemy[enemy[i].x][enemy[i].y] = true; if(false) { IREP(j, 60) { REP(i, 25) { if(is_enemy[i][j]) cerr << "o"; else if(i == cur_x && j == 0) cerr << "X"; else cerr << "."; } cerr << endl; } } //ある敵のみを倒すことを考えて移動した場合を考える //倒した敵の集合を管理 //その敵に相対することのできる位置までの最小距離をDPで求める //その敵を倒せるかどうかを判定 vector> dp(25, vector(60, INF)); vector> dpd(25, vector(60, INF)); dp[cur_x][0] = 0; dpd[cur_x][0] = 0; REP(j, 59) REP(i, 25) if(dp[i][j] != INF) for(int d : {-1, 1, 0}) { int x = (i + d + 25) % 25; int y = j + 1; if(is_enemy[x][y] || is_enemy[x][y-1]) continue; dp[x][y] = dp[i][j] + 1; if(i == cur_x && j == 0) dpd[x][y] = d; else dpd[x][y] = dpd[i][j]; } if(false) { IREP(j, 60) { REP(i, 25) { if(dpd[i][j] == INF) cerr << "x"; else cerr << dpd[i][j]; } cerr << endl; } } int min_value = INF; int best_move = 0; int best_enemy_id = -1; FOR(i, enemy_s, enemy.size()) if(enemy[i].h > 0) { int x = enemy[i].x; int y = enemy[i].y; int miny = INF; while(true) { y--; if(y == -1) break; if(is_enemy[x][y]) break; if(dp[x][y] != INF) miny = y; } if(miny == INF) continue; int dist = enemy[i].y - miny; int need_turn = enemy[i].h / (cur_power / 100) + (enemy[i].h % (cur_power/100) != 0); if(need_turn > dist) continue; if(miny < min_value) { min_value = miny; best_move = dpd[x][miny]; best_enemy_id = i; } } if(best_enemy_id == -1) { best_move = dpd[cur_x][59]; } if(best_move == 0) cout << "S" << endl; else if(best_move == -1) cout << "L" << endl; else cout << "R" << endl; if(best_enemy_id != -1) cout << "# " << enemy[best_enemy_id].x << " " << enemy[best_enemy_id].y << " " << min_value << endl; cout.flush(); cur_x = (cur_x + best_move + 25) % 25; //update int min_y = INF; int damage_enemy = -1; FOR(i, enemy_s, enemy.size()) { if(enemy[i].x == cur_x && enemy[i].y >= 0 && enemy[i].y < min_y && enemy[i].h > 0) { min_y = enemy[i].y; damage_enemy = i; } } if(damage_enemy != -1) { enemy[damage_enemy].h -= (cur_power/100); if(enemy[damage_enemy].h <= 0) cur_power += enemy[damage_enemy].p; } } cerr << cur_power << endl; }