#include // cout, endl, cin #include // string, to_string, stoi #include // vector #include // min, max, swap, sort, reverse, lower_bound, upper_bound #include // pair, make_pair #include // tuple, make_tuple #include // int64_t, int*_t #include // printf #include // map #include // queue, priority_queue #include // set #include // stack #include // deque #include // unordered_map #include // unordered_set #include // bitset #include // isupper, islower, isdigit, toupper, tolower #include //fixed,setprecision //#include //INT_MAX //#include //M_PI #include #include // 正規表現 #include #include //#include using namespace std; #define ll long long #define rep(i, n) for (ll i = 0; i < (ll)(n); i++) constexpr int width = 25; // フィールドの幅 constexpr int height = 60; // フィールドの高さ constexpr int max_turn = 1000; // ゲームの最大ターン数 const char choice[3] = {'L', 'R', 'S'}; int masu[25][60]; int masu1[25][60]; int sx = 12; int power=0; int kogeki=1; struct Data { int h; int p; int x; int y; Data(int h, int p, int x, int y) : h(h), p(p), x(x), y(y) {} }; bool compareByValue(const Data& a, const Data& b) { int valueA = a.y - std::abs(sx - a.x) - 1 - a.h; int valueB = b.y - std::abs(sx - b.x) - 1 - b.h; if (valueA != valueB) return valueA > valueB; else return std::abs(sx - a.x) < std::abs(sx - b.x); } int main() { //vectorP(25); //rep(i,25)cin>>P[i]; vector data,data_mae; rep(i,25)data_mae.emplace_back(-1,-1,-1,-1); for (int turn = 1; turn <= max_turn; turn++) { // 入力の受け取り int n; cin >> n; if (n == -1) return 0; for(auto& z:data_mae)if(z.h<=0){ power+=z.p; if(!data.empty()){ int sho=100; rep(i,data.size()){ if(z.x==data[i].x&&data[i].h>0&&sho>data[i].y){ sho=data[i].y; z.h=data[i].h; z.x=data[i].x; z.p=data[i].p; z.y=data[i].y; } } } } for (int i = 0; i < n; i++) { int h1, p1, x1; cin >> h1 >> p1 >> x1; //cerr<0&&sho>abs(sx-z.x)&&z.y!=-1&&z.x!=-1&&z.h>0){ min_i=z.x; sho=abs(sx-z.x); } } int r = 2; if(!data.empty()){ if(min_i==-1)min_i=sx; //cerr<<"moto sx"< min_i&&sx>=1&&masu[sx-1][0]==0&&masu[sx-1][1]==0&&masu[sx-1][2]==0) { r = 0;//L sx--; } else if (sx < min_i&&sx<24&&masu[sx+1][0]==0&&masu[sx+1][1]==0&&masu[sx+1][2]==0) { r = 1;//R sx++; } else { r = 2; if (masu[sx][0]==1||masu[sx][1]==1||masu[sx][2]==1) { if (sx >= 1&&masu[sx-1][0]==0&&masu[sx-1][1]==0&&masu[sx-1][2]==0) { sx--; r = 0; } else if(sx <24&&masu[sx+1][0]==0&&masu[sx+1][1]==0&&masu[sx+1][2]==0){ sx++; r = 1; }else if(sx==0&&masu[24][0]==0&&masu[24][1]==0&&masu[24][2]==0){ r=0; sx=24; }else if(sx ==24&&masu[0][0]==0&&masu[0][1]==0&&masu[0][2]==0){ r=1; sx=0; } } } } char c = choice[r]; cout << c << endl; cout << "#" << c << " sx:" << sx <=0)masu1[i][j-1]=1; } } } rep(i,25)rep(j,60)masu[i][j]=masu1[i][j]; if (!data.empty()) { for (auto& z : data) { z.y -=1; if (z.x == sx) { ichi = min(ichi, z.y); } } } if (ichi != -1&&!data.empty()) { for (auto it = data.begin(); it != data.end(); ++it) { if (ichi == it->y && it->x == sx) { int z=kogeki; if (it->h >z) { it->h -= z; } else{ data.erase(it); } break; } if(it->h<=0)data.erase(it); } } } return 0; }