結果

問題 No.5017 Tool-assisted Shooting
ユーザー FplusFplusFFplusFplusF
提出日時 2023-07-16 19:18:17
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,521 ms / 2,000 ms
コード長 7,135 bytes
コンパイル時間 3,419 ms
コンパイル使用メモリ 239,520 KB
実行使用メモリ 25,620 KB
スコア 3,588,007
平均クエリ数 1000.00
最終ジャッジ日時 2023-07-16 19:20:48
合計ジャッジ時間 143,838 ms
ジャッジサーバーID
(参考情報)
judge15 / judge9
純コード判定しない問題か言語
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,430 ms
23,980 KB
testcase_01 AC 1,351 ms
23,972 KB
testcase_02 AC 1,192 ms
24,400 KB
testcase_03 AC 1,423 ms
24,464 KB
testcase_04 AC 1,361 ms
23,984 KB
testcase_05 AC 1,364 ms
24,048 KB
testcase_06 AC 1,483 ms
25,284 KB
testcase_07 AC 1,285 ms
24,000 KB
testcase_08 AC 1,391 ms
25,104 KB
testcase_09 AC 1,300 ms
24,144 KB
testcase_10 AC 1,351 ms
25,120 KB
testcase_11 AC 1,323 ms
24,396 KB
testcase_12 AC 1,324 ms
23,784 KB
testcase_13 AC 1,399 ms
25,160 KB
testcase_14 AC 1,378 ms
24,220 KB
testcase_15 AC 1,254 ms
24,440 KB
testcase_16 AC 1,426 ms
24,856 KB
testcase_17 AC 1,436 ms
24,824 KB
testcase_18 AC 1,424 ms
24,084 KB
testcase_19 AC 1,297 ms
24,228 KB
testcase_20 AC 1,322 ms
24,416 KB
testcase_21 AC 1,238 ms
24,652 KB
testcase_22 AC 1,294 ms
23,328 KB
testcase_23 AC 1,355 ms
25,312 KB
testcase_24 AC 1,397 ms
24,540 KB
testcase_25 AC 1,404 ms
24,896 KB
testcase_26 AC 1,165 ms
24,016 KB
testcase_27 AC 1,165 ms
24,488 KB
testcase_28 AC 1,457 ms
25,536 KB
testcase_29 AC 1,430 ms
24,336 KB
testcase_30 AC 1,333 ms
24,340 KB
testcase_31 AC 1,278 ms
24,272 KB
testcase_32 AC 1,223 ms
24,028 KB
testcase_33 AC 1,361 ms
25,620 KB
testcase_34 AC 1,333 ms
24,640 KB
testcase_35 AC 1,261 ms
24,760 KB
testcase_36 AC 1,291 ms
23,920 KB
testcase_37 AC 1,294 ms
24,384 KB
testcase_38 AC 1,317 ms
24,316 KB
testcase_39 AC 1,521 ms
24,224 KB
testcase_40 AC 1,457 ms
24,768 KB
testcase_41 AC 1,413 ms
24,528 KB
testcase_42 AC 1,355 ms
24,284 KB
testcase_43 AC 1,463 ms
24,056 KB
testcase_44 AC 1,393 ms
24,440 KB
testcase_45 AC 1,405 ms
24,616 KB
testcase_46 AC 1,437 ms
23,568 KB
testcase_47 AC 1,277 ms
24,188 KB
testcase_48 AC 1,471 ms
24,980 KB
testcase_49 AC 1,316 ms
24,420 KB
testcase_50 AC 1,295 ms
24,432 KB
testcase_51 AC 1,247 ms
23,944 KB
testcase_52 AC 1,378 ms
24,388 KB
testcase_53 AC 1,289 ms
23,924 KB
testcase_54 AC 1,235 ms
23,936 KB
testcase_55 AC 1,201 ms
23,808 KB
testcase_56 AC 1,436 ms
23,932 KB
testcase_57 AC 1,303 ms
24,284 KB
testcase_58 AC 1,301 ms
23,928 KB
testcase_59 AC 1,386 ms
23,744 KB
testcase_60 AC 1,271 ms
23,428 KB
testcase_61 AC 1,296 ms
24,200 KB
testcase_62 AC 1,245 ms
23,364 KB
testcase_63 AC 1,273 ms
24,776 KB
testcase_64 AC 1,320 ms
24,208 KB
testcase_65 AC 1,364 ms
25,492 KB
testcase_66 AC 1,317 ms
24,656 KB
testcase_67 AC 1,201 ms
24,080 KB
testcase_68 AC 1,292 ms
24,224 KB
testcase_69 AC 1,257 ms
24,996 KB
testcase_70 AC 1,276 ms
25,292 KB
testcase_71 AC 1,261 ms
23,808 KB
testcase_72 AC 1,227 ms
23,440 KB
testcase_73 AC 1,279 ms
24,192 KB
testcase_74 AC 1,310 ms
24,524 KB
testcase_75 AC 1,384 ms
25,516 KB
testcase_76 AC 1,375 ms
24,012 KB
testcase_77 AC 1,449 ms
23,928 KB
testcase_78 AC 1,433 ms
25,076 KB
testcase_79 AC 1,280 ms
23,592 KB
testcase_80 AC 1,425 ms
24,732 KB
testcase_81 AC 1,373 ms
23,572 KB
testcase_82 AC 1,470 ms
25,360 KB
testcase_83 AC 1,252 ms
23,920 KB
testcase_84 AC 1,369 ms
23,904 KB
testcase_85 AC 1,351 ms
23,748 KB
testcase_86 AC 1,341 ms
24,140 KB
testcase_87 AC 1,289 ms
24,416 KB
testcase_88 AC 1,432 ms
24,484 KB
testcase_89 AC 1,414 ms
25,108 KB
testcase_90 AC 1,234 ms
23,984 KB
testcase_91 AC 1,331 ms
24,540 KB
testcase_92 AC 1,218 ms
24,360 KB
testcase_93 AC 1,371 ms
24,272 KB
testcase_94 AC 1,295 ms
24,136 KB
testcase_95 AC 1,430 ms
24,280 KB
testcase_96 AC 1,421 ms
24,408 KB
testcase_97 AC 1,451 ms
24,436 KB
testcase_98 AC 1,355 ms
23,764 KB
testcase_99 AC 1,347 ms
24,796 KB
権限があれば一括ダウンロードができます

ソースコード

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 shooter{
    int j;
    int l;
    int s;
};
struct enemy{
    int fh;
    int h;
    int p;
};
struct state{
    int turn;
    int point;
    vector<vector<enemy>> grid;
    shooter me;
    string root;
};
bool operator<(const state &a,const state &b){
    return (double)a.point/(double)a.turn<(double)b.point/(double)b.turn;
}
struct solver{
    string beam_search(state first_state,int width,int depth){
        priority_queue<state> now_beam,copy_now_beam;
        now_beam.push(first_state);
        rep(d,depth){
            copy_now_beam=now_beam;
            priority_queue<state> next_beam;
            rep(w,width){
                if(now_beam.empty()) break;
                state now_state=now_beam.top();
                now_beam.pop();
                rep(i,H){
                    rep(j,W){
                        if(0<now_state.grid[i][j].h){
                            bool ok=true;
                            for(int k=i+1;k<H;k++){
                                if(0<now_state.grid[k][j].h) ok=false;
                            }
                            if(!ok) continue;
                            int n=H-i,z=abs(j-now_state.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;
                                    if(now_state.me.j<j){
                                        if(0<=H-1-ii&&H-1-ii<H&&0<=H-1-(ii+1)&&H-1-(ii+1)<H&&now_state.grid[H-1-ii][now_state.me.j+jj].h==0&&now_state.grid[H-1-(ii+1)][now_state.me.j+jj].h==0) dp[ii+1][jj]={ii,jj};
                                        if(jj+1<=z&&0<=H-1-ii&&H-1-ii<H&&0<=H-1-(ii+1)&&H-1-(ii+1)<H&&now_state.grid[H-1-ii][now_state.me.j+(jj+1)].h==0&&now_state.grid[H-1-(ii+1)][now_state.me.j+(jj+1)].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&&now_state.grid[H-1-ii][now_state.me.j-jj].h==0&&now_state.grid[H-1-(ii+1)][now_state.me.j-jj].h==0) dp[ii+1][jj]={ii,jj};
                                        if(jj+1<=z&&0<=H-1-ii&&H-1-ii<H&&0<=H-1-(ii+1)&&H-1-(ii+1)<H&&now_state.grid[H-1-ii][now_state.me.j-(jj+1)].h==0&&now_state.grid[H-1-(ii+1)][now_state.me.j-(jj+1)].h==0) dp[ii+1][jj+1]={ii,jj};
                                    }
                                }
                            }
                            int tx=-1;
                            pii pa={-1,-1};
                            rep(ii,n+1){
                                if(dp[ii][z]!=pair<int,int>({-1,-1})){
                                    tx=ii;
                                    pa={ii,z};
                                    break;
                                }
                            }
                            
                            if(tx==-1||0<now_state.grid[i][j].h-(H-1-i-tx)*now_state.me.l) continue;
                            state new_state=now_state;
                            int nt=tx+(now_state.grid[i][j].h+now_state.me.l-1)/now_state.me.l;
                            new_state.turn+=nt;
                            new_state.point+=now_state.grid[i][j].fh;
                            new_state.me.l=1+new_state.point/100;
                            new_state.grid[i][j]={0,0,0};
                            for(int ii=H-1;0<=ii;ii--){
                                rep(jj,W){
                                    new_state.grid[ii][jj]={0,0,0};
                                    if(0<=ii-nt) new_state.grid[ii][jj]=new_state.grid[ii-nt][jj];
                                }
                            }
                            string now_root;
                            while(pa!=pair<int,int>({0,0})){
                                pii new_pa=dp[pa.first][pa.second];
                                if(new_pa.second!=pa.second){
                                    if(new_state.me.j<j) now_root.push_back('R');
                                    else now_root.push_back('L');
                                }else{
                                    now_root.push_back('S');
                                }
                                pa=new_pa;
                            }
                            reverse(all(now_root));
                            rep(ii,nt-tx) now_root.push_back('S');
                            new_state.root+=now_root;
                            //cerr << new_state.root << endl;
                            next_beam.push(new_state);
                        }
                    }
                }
                if(next_beam.empty()){
                    return copy_now_beam.top().root;
                }
                now_beam=next_beam;
                
            }
        }
        return now_beam.top().root;
    }
    void solve(){
        int score=0;
        shooter me={12,1,0};
        vector<vector<enemy>> grid(H,vector<enemy>(W,{0,0,0}));
        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];
            }
            state first_state={0,0,grid,me,""};
                root=beam_search(first_state,5,5);
                reverse(all(root));
            if(root.empty()){
                cout << "S" << endl;
            }else{
                cout << root.back() << endl;
                if(root.back()=='L') me.j--;
                if(root.back()=='R') me.j++;
                root.pop_back();
            }
            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;
                    }
                    break;
                }
            }
            me.l=1+me.s/100;
        }
    }
}Solver;
int main(){
    Solver.solve();
}
0