結果

問題 No.5017 Tool-assisted Shooting
ユーザー FplusFplusFFplusFplusF
提出日時 2023-07-16 17:33:53
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 5,294 bytes
コンパイル時間 3,625 ms
コンパイル使用メモリ 215,724 KB
実行使用メモリ 34,052 KB
スコア 0
最終ジャッジ日時 2023-07-16 17:34:04
合計ジャッジ時間 9,194 ms
ジャッジサーバーID
(参考情報)
judge16 / judge17
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
testcase_49 -- -
testcase_50 -- -
testcase_51 -- -
testcase_52 -- -
testcase_53 -- -
testcase_54 -- -
testcase_55 -- -
testcase_56 -- -
testcase_57 -- -
testcase_58 -- -
testcase_59 -- -
testcase_60 -- -
testcase_61 -- -
testcase_62 -- -
testcase_63 -- -
testcase_64 -- -
testcase_65 -- -
testcase_66 -- -
testcase_67 -- -
testcase_68 -- -
testcase_69 -- -
testcase_70 -- -
testcase_71 -- -
testcase_72 -- -
testcase_73 -- -
testcase_74 -- -
testcase_75 -- -
testcase_76 -- -
testcase_77 -- -
testcase_78 -- -
testcase_79 -- -
testcase_80 -- -
testcase_81 -- -
testcase_82 -- -
testcase_83 -- -
testcase_84 -- -
testcase_85 -- -
testcase_86 -- -
testcase_87 -- -
testcase_88 -- -
testcase_89 -- -
testcase_90 -- -
testcase_91 -- -
testcase_92 -- -
testcase_93 -- -
testcase_94 -- -
testcase_95 -- -
testcase_96 -- -
testcase_97 -- -
testcase_98 -- -
testcase_99 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
const int INF=1e9;
using pii=pair<int,int>;
using tii=tuple<int,int,int>;
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
template<class T> void chmin(T &a,T b){
    if(a>b){
        a=b;
    }
}
template<class T> void chmax(T &a,T b){
    if(a<b){
        a=b;
    }
}
int H=60,W=25;
struct Input{
    int n;
    vector<int> h,p,x;
    void input_cin(){
        cin >> n;
        if(n==-1) exit(0);
        h.assign(n,0);
        p.assign(n,0);
        x.assign(n,0);
        rep(i,n) cin >> h[i] >> p[i] >> x[i];
    }
}Input;
struct solver{
    struct shooter{
        int j;
        int l;
        int s;
    };
    struct enemy{
        int fh;
        int h;
        int p;
    };
    void solve(){
        int score=0;
        shooter me={12,1,0};
        vector<vector<enemy>> grid(H,vector<enemy>(W,{0,0,0}));
        int to=-1;
        string root;
        rep(t,1000){
            for(int i=H-2;0<=i;i--){
                rep(j,W){
                    grid[i+1][j]=grid[i][j];
                    grid[i][j]={0,0,0};
                }
            }
            Input.input_cin();
            rep(i,Input.n){
                grid[0][Input.x[i]].fh=Input.h[i];
                grid[0][Input.x[i]].h=Input.h[i];
                grid[0][Input.x[i]].p=Input.p[i];
            }
            if(to==-1){
                double mx=0;
                int p=-1;
                string mx_root;
                rep(i,H){
                    rep(j,W){
                        if(0<grid[i][j].h){
                            bool ok=true;
                            for(int k=i+1;k<H;k++){
                                if(0<grid[k][j].h) ok=false;
                            }
                            if(!ok) continue;
                            int n=H-i,z=abs(j-me.j);
                            vector<vector<pii>> dp(n+1,vector<pii>(z+1,{-1,-1}));
                            dp[0][0]={-2,-2};
                            rep(ii,n){
                                rep(jj,z+1){
                                    if(dp[ii][jj]==pair<int,int>({-1,-1})) continue;
                                    dp[ii+1][jj]={ii,jj};
                                    if(z<jj+1) continue;
                                    if(me.j<j){
                                        if(0<=H-1-ii&&H-1-ii<H&&0<=H-1-(ii+1)&&H-1-(ii+1)<H&&grid[H-1-ii][me.j+jj].h==0&&grid[H-1-(ii+1)][me.j+jj].h==0) dp[ii+1][jj+1]={ii,jj};
                                    }else{
                                        if(0<=H-1-ii&&H-1-ii<H&&0<=H-1-(ii+1)&&H-1-(ii+1)<H&&grid[H-1-ii][me.j-jj].h==0&&grid[H-1-(ii+1)][me.j-jj].h==0) dp[ii+1][jj+1]={ii,jj};
                                    }
                                }
                            }
                            int t=-1;
                            pii pa={-1,-1};
                            rep(ii,n+1){
                                if(dp[ii][z]!=pair<int,int>({-1,-1})){
                                    t=ii;
                                    pa={ii,z};
                                    break;
                                }
                            }
                            if(t==-1||0<grid[i][j].h-(H-1-i-t)*me.l) continue;
                            double now=(double)grid[i][j].fh/(double)(t+(grid[i][j].h+me.l-1)/me.l);
                            if(mx<now){
                                mx=now;
                                p=j;
                                mx_root="";
                                while(pa!=pair<int,int>({0,0})){
                                    pii new_pa=dp[pa.first][pa.second];
                                    if(new_pa.second!=pa.second){
                                        if(me.j<j) mx_root.push_back('R');
                                        else mx_root.push_back('L');
                                    }else{
                                        mx_root.push_back('S');
                                    }
                                    pa=new_pa;
                                }
                            }
                        }
                    }
                }
                to=p;
                root=mx_root;
            }
            if(to==-1){
                cout << "S" << endl;
            }else if(!root.empty()){
                cout << root.back() << endl;
                if(root.back()=='L') me.j--;
                if(root.back()=='R') me.j++;
                root.pop_back();
            }else{
                cout << "S" << endl;
            }
            for(int i=H-2;0<=i;i--){
                if(0<grid[i][me.j].h){
                    grid[i][me.j].h-=me.l;
                    if(grid[i][me.j].h<=0){
                        score+=grid[i][me.j].fh;
                        grid[i][me.j].fh=0;
                        grid[i][me.j].h=0;
                        me.s+=grid[i][me.j].p;
                        grid[i][me.j].p=0;
                        if(me.j==to) to=-1;
                    }
                    break;
                }
            }
            me.l=1+me.s/100;
        }
    }
}Solver;
int main(){
    //提出時消す
    rep(i,25){
        int p;
        cin >> p;
    }
    Solver.solve();
}
0