結果

問題 No.5017 Tool-assisted Shooting
ユーザー nyyanyya
提出日時 2023-07-16 17:34:54
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 77 ms / 2,000 ms
コード長 11,326 bytes
コンパイル時間 4,056 ms
コンパイル使用メモリ 234,752 KB
実行使用メモリ 24,396 KB
スコア 3,050,037
平均クエリ数 2939.70
最終ジャッジ日時 2023-07-16 17:35:10
合計ジャッジ時間 15,127 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
純コード判定しない問題か言語
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 68 ms
23,412 KB
testcase_01 AC 66 ms
24,144 KB
testcase_02 AC 65 ms
24,084 KB
testcase_03 AC 32 ms
23,700 KB
testcase_04 AC 40 ms
23,460 KB
testcase_05 AC 38 ms
23,448 KB
testcase_06 AC 65 ms
23,400 KB
testcase_07 AC 67 ms
23,400 KB
testcase_08 AC 65 ms
23,556 KB
testcase_09 AC 30 ms
23,544 KB
testcase_10 AC 31 ms
24,060 KB
testcase_11 AC 65 ms
23,616 KB
testcase_12 AC 65 ms
23,652 KB
testcase_13 AC 66 ms
24,072 KB
testcase_14 AC 31 ms
24,072 KB
testcase_15 AC 65 ms
23,700 KB
testcase_16 AC 64 ms
24,288 KB
testcase_17 AC 66 ms
23,664 KB
testcase_18 AC 66 ms
23,676 KB
testcase_19 AC 74 ms
24,036 KB
testcase_20 AC 73 ms
23,856 KB
testcase_21 AC 66 ms
24,084 KB
testcase_22 AC 34 ms
24,072 KB
testcase_23 AC 65 ms
24,372 KB
testcase_24 AC 66 ms
24,048 KB
testcase_25 AC 31 ms
23,436 KB
testcase_26 AC 65 ms
23,436 KB
testcase_27 AC 64 ms
23,580 KB
testcase_28 AC 67 ms
23,652 KB
testcase_29 AC 65 ms
24,096 KB
testcase_30 AC 66 ms
23,436 KB
testcase_31 AC 64 ms
23,868 KB
testcase_32 AC 66 ms
23,436 KB
testcase_33 AC 72 ms
24,276 KB
testcase_34 AC 33 ms
24,036 KB
testcase_35 AC 40 ms
23,424 KB
testcase_36 AC 64 ms
24,036 KB
testcase_37 AC 65 ms
24,384 KB
testcase_38 AC 69 ms
23,580 KB
testcase_39 AC 65 ms
24,288 KB
testcase_40 AC 33 ms
23,568 KB
testcase_41 AC 65 ms
23,700 KB
testcase_42 AC 66 ms
23,700 KB
testcase_43 AC 65 ms
24,396 KB
testcase_44 AC 66 ms
23,712 KB
testcase_45 AC 29 ms
24,096 KB
testcase_46 AC 65 ms
23,880 KB
testcase_47 AC 65 ms
24,360 KB
testcase_48 AC 65 ms
23,700 KB
testcase_49 AC 64 ms
23,856 KB
testcase_50 AC 66 ms
23,580 KB
testcase_51 AC 68 ms
23,652 KB
testcase_52 AC 65 ms
23,388 KB
testcase_53 AC 65 ms
24,072 KB
testcase_54 AC 65 ms
23,436 KB
testcase_55 AC 38 ms
24,312 KB
testcase_56 AC 66 ms
24,384 KB
testcase_57 AC 65 ms
23,664 KB
testcase_58 AC 66 ms
24,072 KB
testcase_59 AC 66 ms
24,060 KB
testcase_60 AC 33 ms
23,868 KB
testcase_61 AC 65 ms
23,460 KB
testcase_62 AC 64 ms
24,036 KB
testcase_63 AC 66 ms
24,144 KB
testcase_64 AC 65 ms
23,712 KB
testcase_65 AC 67 ms
23,880 KB
testcase_66 AC 35 ms
24,060 KB
testcase_67 AC 65 ms
23,892 KB
testcase_68 AC 66 ms
23,676 KB
testcase_69 AC 35 ms
23,580 KB
testcase_70 AC 71 ms
23,460 KB
testcase_71 AC 41 ms
23,400 KB
testcase_72 AC 65 ms
24,072 KB
testcase_73 AC 65 ms
24,096 KB
testcase_74 AC 64 ms
24,396 KB
testcase_75 AC 31 ms
23,424 KB
testcase_76 AC 65 ms
23,880 KB
testcase_77 AC 65 ms
24,372 KB
testcase_78 AC 70 ms
24,060 KB
testcase_79 AC 66 ms
23,676 KB
testcase_80 AC 67 ms
24,300 KB
testcase_81 AC 32 ms
23,868 KB
testcase_82 AC 69 ms
23,448 KB
testcase_83 AC 77 ms
24,288 KB
testcase_84 AC 67 ms
24,024 KB
testcase_85 AC 66 ms
24,024 KB
testcase_86 AC 68 ms
23,460 KB
testcase_87 AC 67 ms
24,048 KB
testcase_88 AC 68 ms
24,024 KB
testcase_89 AC 34 ms
24,372 KB
testcase_90 AC 66 ms
23,400 KB
testcase_91 AC 66 ms
24,048 KB
testcase_92 AC 65 ms
23,400 KB
testcase_93 AC 65 ms
24,384 KB
testcase_94 AC 68 ms
23,892 KB
testcase_95 AC 66 ms
24,384 KB
testcase_96 AC 30 ms
24,300 KB
testcase_97 AC 65 ms
23,556 KB
testcase_98 AC 64 ms
23,400 KB
testcase_99 AC 64 ms
24,300 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(),x.end() 
typedef long long ll;
//using mint = modint;
//using mint = modint998244353;
using mint = modint1000000007;
using P = pair<int, int>;

const ll INF=1LL<<60, dx[]={0,1,0,-1},dy[]={1,0,-1,0};
template <typename T> inline bool chmin(T& a,const T&b) {if(a>b){a=b; return 1;} return 0;}
template <typename T> inline bool chmax(T& a,const T&b) {if(a<b){a=b; return 1;} return 0;}

const int W = 25;
const int H = 60;
const int T = 1000;

class Enemy {
public:
    int MaxHp;
    int NowHp;
    int Power;
};

int Field[25][1070];

int main(){

    //vector<int> P(25);
    //rep(i,25) cin >> P[i];

    int MyX=12,MyY=0,S=0,MyPower=0;
    vector<Enemy> enemies(1);
    vector<vector<int>> colEnemy(25);

    int enemyNum = 0;

    rep(ti,T) {
        int n;
        cin >> n;
        if(n==-1) return 0;

        MyY++;
        
        //読み込み
        vector<int> h(n),p(n),x(n);
        rep(i,n) {
            enemyNum++;
            cin >> h[i] >> p[i] >> x[i];
            auto enemy = Enemy();
            enemy.MaxHp = h[i];
            enemy.NowHp = h[i];
            enemy.Power = p[i];
            Field[x[i]][ti+H] = enemyNum;
            enemies.push_back(enemy);
            colEnemy[x[i]].push_back(ti+H);
        }

        //選択
        int level = 1 + MyPower/100;
        auto it = lower_bound(colEnemy[MyX].begin(),colEnemy[MyX].end(),MyY);
        if(it==colEnemy[MyX].end()) {
            int MyXL = (MyX+24)%25;
            int MyXR = (MyX+ 1)%25;

            auto itl = lower_bound(colEnemy[MyXL].begin(),colEnemy[MyXL].end(),MyY);
            auto itr = lower_bound(colEnemy[MyXR].begin(),colEnemy[MyXR].end(),MyY);

            if(itl==colEnemy[MyXL].end() && itr==colEnemy[MyXR].end()) {
                cout << "L" << endl;
                MyX = MyXL;
            } else if(itl==colEnemy[MyXL].end() && itr!=colEnemy[MyXR].end()) {
                int enemyNoR = Field[MyXR][*itr];
                if(enemies[enemyNoR].NowHp>(*itr-MyY)*level) {
                    cout << "L" << endl;
                    MyX = MyXL;
                } else {
                    cout << "R" << endl;
                    MyX = MyXR;
                    enemies[enemyNoR].NowHp = max(0,enemies[enemyNoR].NowHp-level);
                    if(enemies[enemyNoR].NowHp==0) {
                        S += enemies[enemyNoR].MaxHp;
                        MyPower += enemies[enemyNoR].Power;
                        colEnemy[MyX].erase(itr);
                    }
                } 
            } else if(itl!=colEnemy[MyXL].end() && itr==colEnemy[MyXR].end()) {
                int enemyNoL = Field[MyXL][*itl];
                if(enemies[enemyNoL].NowHp>(*itl-MyY)*level) {
                    cout << "R" << endl;
                    MyX = MyXR;
                } else {
                    cout << "L" << endl;
                    MyX = MyXL;
                    enemies[enemyNoL].NowHp = max(0,enemies[enemyNoL].NowHp-level);
                    if(enemies[enemyNoL].NowHp==0) {
                        S += enemies[enemyNoL].MaxHp;
                        MyPower += enemies[enemyNoL].Power;
                        colEnemy[MyX].erase(itl);
                    }
                }
            } else {
                int enemyNoR = Field[MyXR][*itr];
                int enemyNoL = Field[MyXL][*itl];
                if(enemies[enemyNoR].NowHp>(*itr-MyY)*level && enemies[enemyNoL].NowHp>(*itl-MyY)*level) {
                    cout << "S" << endl;
                } else if(enemies[enemyNoR].NowHp>(*itr-MyY)*level){
                    cout << "L" << endl;
                    MyX = MyXL;
                    enemies[enemyNoL].NowHp = max(0,enemies[enemyNoL].NowHp-level);
                    if(enemies[enemyNoL].NowHp==0) {
                        S += enemies[enemyNoL].MaxHp;
                        MyPower += enemies[enemyNoL].Power;
                        colEnemy[MyX].erase(itl);
                    }
                } else if(enemies[enemyNoL].NowHp>(*itl-MyY)*level){
                    cout << "R" << endl;
                    MyX = MyXR;
                    enemies[enemyNoR].NowHp = max(0,enemies[enemyNoR].NowHp-level);
                    if(enemies[enemyNoR].NowHp==0) {
                        S += enemies[enemyNoR].MaxHp;
                        MyPower += enemies[enemyNoR].Power;
                        colEnemy[MyX].erase(itr);
                    }
                } else {
                    int nl = colEnemy[MyXL].end() - itl;
                    int nr = colEnemy[MyXR].end() - itr;
                    if(nl<nr) {
                        cout << "R" << endl;
                        MyX = MyXR;
                        enemies[enemyNoR].NowHp = max(0,enemies[enemyNoR].NowHp-level);
                        if(enemies[enemyNoR].NowHp==0) {
                            S += enemies[enemyNoR].MaxHp;
                            MyPower += enemies[enemyNoR].Power;
                            colEnemy[MyX].erase(itr);
                        }
                    } else {
                        cout << "L" << endl;
                        MyX = MyXL;
                        enemies[enemyNoL].NowHp = max(0,enemies[enemyNoL].NowHp-level);
                        if(enemies[enemyNoL].NowHp==0) {
                            S += enemies[enemyNoL].MaxHp;
                            MyPower += enemies[enemyNoL].Power;
                            colEnemy[MyX].erase(itl);
                        }
                    }
                }
            }

        } else {
            int enemyNo = Field[MyX][*it];
            if(enemies[enemyNo].NowHp>(*it-MyY)*level) {
                int MyXL = (MyX+24)%25;
                int MyXR = (MyX+ 1)%25;

                auto itl = lower_bound(colEnemy[MyXL].begin(),colEnemy[MyXL].end(),MyY);
                auto itr = lower_bound(colEnemy[MyXR].begin(),colEnemy[MyXR].end(),MyY);

                if(itl==colEnemy[MyXL].end() && itr==colEnemy[MyXR].end()) {
                    cout << "L" << endl;
                    MyX = MyXL;
                } else if(itl==colEnemy[MyXL].end() && itr!=colEnemy[MyXR].end()) {
                    int enemyNoR = Field[MyXR][*itr];
                    if(enemies[enemyNoR].NowHp>(*itr-MyY)*level) {
                        cout << "L" << endl;
                        MyX = MyXL;
                    } else {
                        cout << "R" << endl;
                        MyX = MyXR;
                        enemies[enemyNoR].NowHp = max(0,enemies[enemyNoR].NowHp-level);
                        if(enemies[enemyNoR].NowHp==0) {
                            S += enemies[enemyNoR].MaxHp;
                            MyPower += enemies[enemyNoR].Power;
                            colEnemy[MyX].erase(itr);
                        }
                    }
                } else if(itl!=colEnemy[MyXL].end() && itr==colEnemy[MyXR].end()) {
                    int enemyNoL = Field[MyXL][*itl];
                    if(enemies[enemyNoL].NowHp>(*itl-MyY)*level) {
                        cout << "R" << endl;
                        MyX = MyXR;
                    } else {
                        cout << "L" << endl;
                        MyX = MyXL;
                        enemies[enemyNoL].NowHp = max(0,enemies[enemyNoL].NowHp-level);
                        if(enemies[enemyNoL].NowHp==0) {
                            S += enemies[enemyNoL].MaxHp;
                            MyPower += enemies[enemyNoL].Power;
                            colEnemy[MyX].erase(itl);
                        }
                    }
                } else {
                    int enemyNoR = Field[MyXR][*itr];
                    int enemyNoL = Field[MyXL][*itl];
                    if(enemies[enemyNoR].NowHp>(*itr-MyY)*level && enemies[enemyNoL].NowHp>(*itl-MyY)*level) {
                        if(*itr>*itl) {
                            cout << "R" << endl;
                            MyX = MyXR;
                            enemies[enemyNoR].NowHp = max(0,enemies[enemyNoR].NowHp-level);
                            if(enemies[enemyNoR].NowHp==0) {
                                S += enemies[enemyNoR].MaxHp;
                                MyPower += enemies[enemyNoR].Power;
                                colEnemy[MyX].erase(itr);
                            }
                        } else {
                            cout << "L" << endl;
                            MyX = MyXL;
                            enemies[enemyNoL].NowHp = max(0,enemies[enemyNoL].NowHp-level);
                            if(enemies[enemyNoL].NowHp==0) {
                                S += enemies[enemyNoL].MaxHp;
                                MyPower += enemies[enemyNoL].Power;
                                colEnemy[MyX].erase(itl);
                            }
                        }
                    } else if(enemies[enemyNoR].NowHp>(*itr-MyY)*level){
                        cout << "L" << endl;
                        MyX = MyXL;
                        enemies[enemyNoL].NowHp = max(0,enemies[enemyNoL].NowHp-level);
                        if(enemies[enemyNoL].NowHp==0) {
                            S += enemies[enemyNoL].MaxHp;
                            MyPower += enemies[enemyNoL].Power;
                            colEnemy[MyX].erase(itl);
                        }
                    } else {
                        int nl = colEnemy[MyXL].end() - itl;
                        int nr = colEnemy[MyXR].end() - itr;
                        if(nl<nr) {
                            cout << "R" << endl;
                            MyX = MyXR;
                            enemies[enemyNoR].NowHp = max(0,enemies[enemyNoR].NowHp-level);
                            if(enemies[enemyNoR].NowHp==0) {
                                S += enemies[enemyNoR].MaxHp;
                                MyPower += enemies[enemyNoR].Power;
                                colEnemy[MyX].erase(itr);
                            }
                        } else {
                            cout << "L" << endl;
                            MyX = MyXL;
                            enemies[enemyNoL].NowHp = max(0,enemies[enemyNoL].NowHp-level);
                            if(enemies[enemyNoL].NowHp==0) {
                                S += enemies[enemyNoL].MaxHp;
                                MyPower += enemies[enemyNoL].Power;
                                colEnemy[MyX].erase(itl);
                            }
                        }
                        
                    }
                }
            } else {
                cout << "S" << endl;
                enemies[enemyNo].NowHp = max(0,enemies[enemyNo].NowHp-level);
                if(enemies[enemyNo].NowHp==0) {
                    S += enemies[enemyNo].MaxHp;
                    MyPower += enemies[enemyNo].Power;
                    colEnemy[MyX].erase(it);
                }

                cout << "#MyX,MyY:" << MyX << " " << MyY << "\n";
                cout << "#EnemyNo:" << enemyNo << "\n";
                cout << "#EnemyHp:" << enemies[enemyNo].NowHp << "\n";
            }
        }
        
    }

    return 0;

}
0