結果

問題 No.5017 Tool-assisted Shooting
ユーザー nyyanyya
提出日時 2023-07-16 16:44:42
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 74 ms / 2,000 ms
コード長 9,470 bytes
コンパイル時間 4,134 ms
コンパイル使用メモリ 233,992 KB
実行使用メモリ 24,420 KB
スコア 3,550,957
平均クエリ数 3367.84
最終ジャッジ日時 2023-07-16 16:44:59
合計ジャッジ時間 15,050 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
純コード判定しない問題か言語
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 65 ms
24,276 KB
testcase_01 AC 64 ms
23,424 KB
testcase_02 AC 64 ms
23,424 KB
testcase_03 AC 63 ms
24,036 KB
testcase_04 AC 64 ms
23,556 KB
testcase_05 AC 64 ms
24,420 KB
testcase_06 AC 63 ms
24,024 KB
testcase_07 AC 63 ms
24,396 KB
testcase_08 AC 64 ms
24,012 KB
testcase_09 AC 74 ms
23,664 KB
testcase_10 AC 64 ms
23,844 KB
testcase_11 AC 64 ms
24,072 KB
testcase_12 AC 64 ms
23,256 KB
testcase_13 AC 64 ms
23,664 KB
testcase_14 AC 29 ms
24,012 KB
testcase_15 AC 64 ms
23,388 KB
testcase_16 AC 31 ms
24,036 KB
testcase_17 AC 65 ms
24,276 KB
testcase_18 AC 64 ms
23,376 KB
testcase_19 AC 29 ms
23,664 KB
testcase_20 AC 65 ms
24,276 KB
testcase_21 AC 64 ms
23,640 KB
testcase_22 AC 73 ms
24,036 KB
testcase_23 AC 64 ms
24,336 KB
testcase_24 AC 64 ms
24,036 KB
testcase_25 AC 65 ms
23,556 KB
testcase_26 AC 65 ms
23,544 KB
testcase_27 AC 64 ms
23,832 KB
testcase_28 AC 66 ms
23,628 KB
testcase_29 AC 64 ms
23,424 KB
testcase_30 AC 63 ms
23,652 KB
testcase_31 AC 64 ms
24,012 KB
testcase_32 AC 64 ms
23,400 KB
testcase_33 AC 65 ms
24,024 KB
testcase_34 AC 74 ms
23,640 KB
testcase_35 AC 64 ms
24,060 KB
testcase_36 AC 63 ms
24,036 KB
testcase_37 AC 64 ms
24,036 KB
testcase_38 AC 64 ms
23,856 KB
testcase_39 AC 64 ms
24,384 KB
testcase_40 AC 64 ms
23,436 KB
testcase_41 AC 64 ms
23,424 KB
testcase_42 AC 64 ms
24,324 KB
testcase_43 AC 64 ms
23,664 KB
testcase_44 AC 65 ms
23,388 KB
testcase_45 AC 65 ms
24,024 KB
testcase_46 AC 73 ms
23,532 KB
testcase_47 AC 66 ms
24,264 KB
testcase_48 AC 65 ms
24,048 KB
testcase_49 AC 64 ms
23,388 KB
testcase_50 AC 65 ms
24,252 KB
testcase_51 AC 31 ms
23,424 KB
testcase_52 AC 64 ms
23,388 KB
testcase_53 AC 64 ms
23,976 KB
testcase_54 AC 65 ms
23,424 KB
testcase_55 AC 64 ms
24,036 KB
testcase_56 AC 63 ms
24,036 KB
testcase_57 AC 64 ms
23,976 KB
testcase_58 AC 73 ms
24,072 KB
testcase_59 AC 65 ms
23,652 KB
testcase_60 AC 63 ms
23,388 KB
testcase_61 AC 63 ms
23,556 KB
testcase_62 AC 64 ms
23,400 KB
testcase_63 AC 64 ms
23,388 KB
testcase_64 AC 65 ms
24,348 KB
testcase_65 AC 69 ms
23,640 KB
testcase_66 AC 64 ms
23,652 KB
testcase_67 AC 65 ms
24,336 KB
testcase_68 AC 65 ms
23,544 KB
testcase_69 AC 64 ms
23,376 KB
testcase_70 AC 73 ms
24,024 KB
testcase_71 AC 65 ms
24,036 KB
testcase_72 AC 64 ms
23,856 KB
testcase_73 AC 64 ms
23,628 KB
testcase_74 AC 64 ms
24,384 KB
testcase_75 AC 65 ms
23,400 KB
testcase_76 AC 65 ms
23,400 KB
testcase_77 AC 65 ms
24,036 KB
testcase_78 AC 65 ms
24,036 KB
testcase_79 AC 64 ms
24,264 KB
testcase_80 AC 66 ms
23,844 KB
testcase_81 AC 64 ms
23,844 KB
testcase_82 AC 73 ms
24,024 KB
testcase_83 AC 65 ms
24,060 KB
testcase_84 AC 65 ms
24,360 KB
testcase_85 AC 66 ms
23,700 KB
testcase_86 AC 65 ms
23,640 KB
testcase_87 AC 64 ms
23,544 KB
testcase_88 AC 65 ms
24,036 KB
testcase_89 AC 65 ms
24,348 KB
testcase_90 AC 64 ms
23,832 KB
testcase_91 AC 65 ms
24,336 KB
testcase_92 AC 64 ms
23,532 KB
testcase_93 AC 63 ms
24,384 KB
testcase_94 AC 63 ms
23,832 KB
testcase_95 AC 64 ms
23,844 KB
testcase_96 AC 64 ms
23,652 KB
testcase_97 AC 63 ms
23,568 KB
testcase_98 AC 63 ms
24,024 KB
testcase_99 AC 64 ms
23,424 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 {
                    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 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 {
                        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 << "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