結果

問題 No.5017 Tool-assisted Shooting
ユーザー FplusFplusFFplusFplusF
提出日時 2023-08-08 09:36:33
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,817 ms / 2,000 ms
コード長 6,184 bytes
コンパイル時間 4,316 ms
コンパイル使用メモリ 274,360 KB
実行使用メモリ 24,456 KB
スコア 4,233,801
平均クエリ数 1000.00
最終ジャッジ日時 2023-08-08 09:39:47
合計ジャッジ時間 190,693 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
純コード判定しない問題か言語
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,764 ms
24,168 KB
testcase_01 AC 1,760 ms
23,676 KB
testcase_02 AC 1,754 ms
23,376 KB
testcase_03 AC 1,759 ms
24,072 KB
testcase_04 AC 1,756 ms
23,412 KB
testcase_05 AC 1,777 ms
23,880 KB
testcase_06 AC 1,754 ms
23,424 KB
testcase_07 AC 1,759 ms
23,448 KB
testcase_08 AC 1,774 ms
23,664 KB
testcase_09 AC 1,761 ms
24,312 KB
testcase_10 AC 1,763 ms
23,964 KB
testcase_11 AC 1,741 ms
24,096 KB
testcase_12 AC 1,740 ms
23,412 KB
testcase_13 AC 1,761 ms
23,604 KB
testcase_14 AC 1,772 ms
23,652 KB
testcase_15 AC 1,759 ms
23,352 KB
testcase_16 AC 1,745 ms
23,364 KB
testcase_17 AC 1,773 ms
23,556 KB
testcase_18 AC 1,771 ms
23,400 KB
testcase_19 AC 1,767 ms
23,976 KB
testcase_20 AC 1,772 ms
23,184 KB
testcase_21 AC 1,765 ms
23,976 KB
testcase_22 AC 1,724 ms
23,976 KB
testcase_23 AC 1,723 ms
23,964 KB
testcase_24 AC 1,770 ms
23,664 KB
testcase_25 AC 1,775 ms
24,300 KB
testcase_26 AC 1,772 ms
23,988 KB
testcase_27 AC 1,760 ms
23,352 KB
testcase_28 AC 1,768 ms
23,400 KB
testcase_29 AC 1,764 ms
24,312 KB
testcase_30 AC 1,770 ms
24,456 KB
testcase_31 AC 1,754 ms
24,384 KB
testcase_32 AC 1,773 ms
23,448 KB
testcase_33 AC 1,801 ms
23,484 KB
testcase_34 AC 1,773 ms
23,568 KB
testcase_35 AC 1,784 ms
24,180 KB
testcase_36 AC 1,786 ms
23,364 KB
testcase_37 AC 1,803 ms
23,364 KB
testcase_38 AC 1,796 ms
23,664 KB
testcase_39 AC 1,782 ms
24,300 KB
testcase_40 AC 1,791 ms
24,336 KB
testcase_41 AC 1,791 ms
23,568 KB
testcase_42 AC 1,799 ms
23,580 KB
testcase_43 AC 1,761 ms
23,952 KB
testcase_44 AC 1,792 ms
24,444 KB
testcase_45 AC 1,789 ms
23,952 KB
testcase_46 AC 1,804 ms
23,580 KB
testcase_47 AC 1,783 ms
24,300 KB
testcase_48 AC 1,798 ms
24,096 KB
testcase_49 AC 1,796 ms
23,772 KB
testcase_50 AC 1,807 ms
24,072 KB
testcase_51 AC 1,787 ms
24,372 KB
testcase_52 AC 1,798 ms
24,096 KB
testcase_53 AC 1,770 ms
23,952 KB
testcase_54 AC 1,800 ms
23,580 KB
testcase_55 AC 1,758 ms
24,348 KB
testcase_56 AC 1,758 ms
23,364 KB
testcase_57 AC 1,771 ms
23,964 KB
testcase_58 AC 1,778 ms
23,676 KB
testcase_59 AC 1,796 ms
23,604 KB
testcase_60 AC 1,787 ms
23,448 KB
testcase_61 AC 1,796 ms
23,964 KB
testcase_62 AC 1,771 ms
23,676 KB
testcase_63 AC 1,780 ms
23,424 KB
testcase_64 AC 1,781 ms
24,180 KB
testcase_65 AC 1,817 ms
23,544 KB
testcase_66 AC 1,759 ms
23,880 KB
testcase_67 AC 1,781 ms
24,300 KB
testcase_68 AC 1,749 ms
23,688 KB
testcase_69 AC 1,780 ms
23,676 KB
testcase_70 AC 1,802 ms
23,592 KB
testcase_71 AC 1,786 ms
24,432 KB
testcase_72 AC 1,783 ms
24,180 KB
testcase_73 AC 1,790 ms
24,060 KB
testcase_74 AC 1,764 ms
23,448 KB
testcase_75 AC 1,803 ms
24,348 KB
testcase_76 AC 1,788 ms
24,276 KB
testcase_77 AC 1,799 ms
23,364 KB
testcase_78 AC 1,752 ms
24,276 KB
testcase_79 AC 1,771 ms
23,688 KB
testcase_80 AC 1,772 ms
23,664 KB
testcase_81 AC 1,762 ms
23,568 KB
testcase_82 AC 1,747 ms
23,496 KB
testcase_83 AC 1,760 ms
23,784 KB
testcase_84 AC 1,759 ms
23,412 KB
testcase_85 AC 1,771 ms
23,448 KB
testcase_86 AC 1,772 ms
23,556 KB
testcase_87 AC 1,761 ms
23,460 KB
testcase_88 AC 1,775 ms
23,364 KB
testcase_89 AC 1,737 ms
23,688 KB
testcase_90 AC 1,762 ms
24,108 KB
testcase_91 AC 1,765 ms
23,880 KB
testcase_92 AC 1,760 ms
23,580 KB
testcase_93 AC 1,769 ms
23,568 KB
testcase_94 AC 1,757 ms
23,688 KB
testcase_95 AC 1,764 ms
24,336 KB
testcase_96 AC 1,771 ms
23,364 KB
testcase_97 AC 1,758 ms
24,288 KB
testcase_98 AC 1,761 ms
24,324 KB
testcase_99 AC 1,735 ms
24,324 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,T=1000;
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 i;
    int j;
    int l;
    int s;
};
struct enemy{
    int i;
    int fh;
    int h;
    int p;
};
struct state{
    int turn;
    double point;
    vector<queue<enemy>> q_enemy;
    shooter me;
    string root;
};
bool operator<(const state &a,const state &b){
    return (double)a.point*(double)a.me.l<(double)b.point*(double)b.me.l;
}
bool operator>(const state &a,const state &b){
    return (double)a.point*(double)a.me.l>(double)b.point*(double)b.me.l;
}
struct solver{
    string beam_search(int now_turn,state first_state,int depth,int width){
        vector<state> now_beam,next_beam;
        now_beam.push_back(first_state);
        rep(d,depth){
            rep(w,width){
                if((int)now_beam.size()<=w) break;
                rep(m,3){
                    state new_state=now_beam[w];
                    if(m==0){
                        new_state.root.push_back('S');
                    }
                    if(m==1){
                        new_state.me.j--;
                        if(new_state.me.j<0) new_state.me.j+=W;
                        new_state.root.push_back('L');
                    }
                    if(m==2){
                        new_state.me.j++;
                        if(W<=new_state.me.j) new_state.me.j-=W;
                        new_state.root.push_back('R');
                    }
                    if(!new_state.q_enemy[new_state.me.j].empty()&&new_state.me.i==new_state.q_enemy[new_state.me.j].front().i) new_state.point=-1e9;
                    if(!new_state.q_enemy[new_state.me.j].empty()&&0<new_state.q_enemy[new_state.me.j].front().h){
                        new_state.q_enemy[new_state.me.j].front().h-=new_state.me.l;
                        if(new_state.root.back()=='S') new_state.point+=T-now_turn;
                        if(new_state.q_enemy[new_state.me.j].front().h<=0){
                            /*if(now_turn<=300) new_state.point+=new_state.q_enemy[new_state.me.j].front().fh*new_state.q_enemy[new_state.me.j].front().fh;
                            else new_state.point+=new_state.q_enemy[new_state.me.j].front().fh*new_state.q_enemy[new_state.me.j].front().p;*/
                            new_state.point+=new_state.q_enemy[new_state.me.j].front().fh;
                            new_state.point+=(depth-(new_state.turn-now_turn))*(depth-(new_state.turn-now_turn));
                            new_state.me.s+=new_state.q_enemy[new_state.me.j].front().p;
                            new_state.q_enemy[new_state.me.j].pop();
                        }
                    }else{
                        int now_d=2;
                        if(300<=now_turn) now_d=5;
                        new_state.point-=now_d;
                        int sz=new_state.root.size();
                        if(1<=sz&&new_state.root[sz-1]=='S') new_state.point-=now_d;
                        if(2<=sz&&((new_state.root[sz-1]=='L'&&new_state.root[sz-2]=='R')||(new_state.root[sz-1]=='R'&&new_state.root[sz-2]=='L'))) new_state.point-=now_d;
                    }
                    new_state.me.l=1+new_state.me.s/100;
                    new_state.me.i--;
                    rep(j,W){
                        if(!new_state.q_enemy[j].empty()&&new_state.me.i<new_state.q_enemy[j].front().i){
                            new_state.point-=new_state.q_enemy[j].front().fh-new_state.q_enemy[j].front().h;
                            new_state.q_enemy[j].pop();
                        }
                    }
                    if(!new_state.q_enemy[new_state.me.j].empty()&&new_state.me.i==new_state.q_enemy[new_state.me.j].front().i) new_state.point=-1e9;
                    new_state.turn++;
                    next_beam.push_back(new_state);
                }
            }
            partial_sort(next_beam.begin(),next_beam.begin()+min((int)next_beam.size(),width),next_beam.end(),[](state &a,state &b){return a>b;});
            swap(now_beam,next_beam);
            next_beam.clear();
        }
        return now_beam.front().root;
    }
    void solve(){
        int score=0;
        shooter me={H+T,12,1,0};
        vector<queue<enemy>> q_enemy(W);
        string root;
        rep(t,T){
            me.i--;
            rep(j,W){
                if(!q_enemy[j].empty()&&me.i<q_enemy[j].front().i) q_enemy[j].pop();
            }
            if(!q_enemy[me.j].empty()&&me.i==q_enemy[me.j].front().i) assert(0);
            Input.input_cin();
            rep(i,Input.n){
                q_enemy[Input.x[i]].push({me.i-H+1,Input.h[i],Input.h[i],Input.p[i]});
            }
            state first_state={0,0,q_enemy,me,""};
            if(t%4==0){
                root=beam_search(t,first_state,20,18);
                reverse(all(root));
            }
            char c=root.back();
            cout << c << endl;
            if(c=='L'){
                me.j--;
                if(me.j<0) me.j+=W;
            }
            if(c=='R'){
                me.j++;
                if(W<=me.j) me.j-=W;
            }
            root.pop_back();
            if(!q_enemy[me.j].empty()&&me.i==q_enemy[me.j].front().i) assert(0);
            if(!q_enemy[me.j].empty()&&0<q_enemy[me.j].front().h){
                q_enemy[me.j].front().h-=me.l;
                if(q_enemy[me.j].front().h<=0){
                    score+=q_enemy[me.j].front().fh;
                    me.s+=q_enemy[me.j].front().p;
                    q_enemy[me.j].pop();
                }
            }
            me.l=1+me.s/100;
            
        }
    }
}Solver;
int main(){
    Solver.solve();
}
0