#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include const long double pi = acos(-1); using namespace std; #define DEBUG 0 #define ll long long #define ull unsigned long long #define ld long double int h = 60; int w = 25; int mid = 12; int can_decide(bool l, bool s, bool r) { int n_true = 0; if (l == true) { n_true++; } if (s == true) { n_true++; } if (r == true) { n_true++; } return n_true; } char next_col(int pos, vector &col) { if (col[pos] > 0) { return 'S'; } int n_l, n_r; int p_l, p_r; for (int i = 1;i < 24;i++) { n_l = 0, n_r = 0; p_l = pos - 1; p_r = pos + i; if (p_l >= 0) { n_l = col[p_l]; } if (p_r < w) { n_r = col[p_r]; } if (n_l != 0 || n_r != 0) { if (n_r < n_l) { return'L'; } else if (n_r > n_l) { return 'R'; } else { return abs(mid - (p_l)) < abs(mid - (p_r)) ? 'L' : 'R'; } } } return pos == 12 ? 'S' : (pos > 12 ? 'L' : 'R'); } int main() { int mypos = 12; char action = 'S'; int powsum = 0; int level = 1; int point = 0; bool can_s = true, can_l = true, can_r = true; vector>> enemy_board(h,vector>(w));//{hp,power} vector> has_enemy(h, vector(w,0)); vector col(w,0); while (true) { int n; cin >> n; if (n == -1) { return 0; } for (int i = 0;i < h - 1;i++) {//update for (int j = 0;j < w;j++) { enemy_board[i + 1][j] = enemy_board[i][j]; has_enemy[i + 1][j] = has_enemy[i][j]; } } for (int i = 0;i < n;i++) {//input int hp, power, x; cin >> hp >> power >> x; enemy_board[0][x].first = hp; enemy_board[0][x].second = power; has_enemy[0][x] = true; col[x]++; } //decision,check can_s = true, can_l = true, can_r = true; if (mypos != 0) { if (has_enemy[h - 1][mypos - 1] == true) { can_l = false; } } else if (mypos != w - 1) { if (has_enemy[h - 1][mypos + 1] == true) { can_r = false; } } if (can_decide(can_l, can_s, can_r) ==0){ action = 'S'; } else if (can_decide(can_l, can_s, can_r) == 1) { if (can_l == true) { action = 'L'; } else if (can_s == true) { action = 'S'; } else { action = 'R'; } } else { action = next_col(mypos, col); } //output cout << action << endl; //action if (action == 'S') { } else if (action == 'R') { mypos++; } else { mypos--; } for (int i = h - 1;i > 0;i--) {//look ahead if (has_enemy[i][mypos] == true) {//敵がいたら enemy_board[i][mypos].first -= level;//hp減らす if (enemy_board[i][mypos].first <= 0) {//敵を倒したら has_enemy[i][mypos] = false;//敵が消滅 powsum += enemy_board[i][mypos].second;//パワー更新 level = 1 + (int)floorl(powsum / 100);//レベル更新 point += enemy_board[i][mypos].first;//得点更新 col[mypos]--; } } } } }