結果

問題 No.5017 Tool-assisted Shooting
ユーザー n-injan-inja
提出日時 2023-07-16 18:25:15
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 81 ms / 2,000 ms
コード長 6,494 bytes
コンパイル時間 1,584 ms
コンパイル使用メモリ 131,732 KB
実行使用メモリ 24,324 KB
スコア 3,673,241
平均クエリ数 1923.70
最終ジャッジ日時 2023-07-16 18:25:32
合計ジャッジ時間 13,797 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
純コード判定しない問題か言語
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
23,532 KB
testcase_01 AC 76 ms
23,400 KB
testcase_02 AC 72 ms
23,424 KB
testcase_03 AC 70 ms
24,144 KB
testcase_04 AC 68 ms
23,580 KB
testcase_05 AC 75 ms
23,640 KB
testcase_06 AC 70 ms
23,508 KB
testcase_07 AC 70 ms
23,304 KB
testcase_08 AC 71 ms
24,144 KB
testcase_09 AC 75 ms
23,712 KB
testcase_10 AC 75 ms
23,412 KB
testcase_11 AC 74 ms
24,216 KB
testcase_12 AC 74 ms
23,820 KB
testcase_13 AC 74 ms
23,496 KB
testcase_14 AC 38 ms
24,012 KB
testcase_15 AC 75 ms
23,508 KB
testcase_16 AC 28 ms
24,264 KB
testcase_17 AC 76 ms
24,012 KB
testcase_18 AC 74 ms
23,628 KB
testcase_19 AC 77 ms
23,628 KB
testcase_20 AC 73 ms
23,904 KB
testcase_21 AC 38 ms
24,144 KB
testcase_22 AC 69 ms
23,532 KB
testcase_23 AC 73 ms
24,264 KB
testcase_24 AC 73 ms
23,532 KB
testcase_25 AC 76 ms
23,496 KB
testcase_26 AC 75 ms
23,892 KB
testcase_27 AC 76 ms
23,628 KB
testcase_28 AC 73 ms
23,256 KB
testcase_29 AC 75 ms
23,292 KB
testcase_30 AC 69 ms
24,264 KB
testcase_31 AC 74 ms
24,312 KB
testcase_32 AC 75 ms
23,400 KB
testcase_33 AC 73 ms
23,256 KB
testcase_34 AC 73 ms
23,520 KB
testcase_35 AC 43 ms
24,012 KB
testcase_36 AC 75 ms
24,324 KB
testcase_37 AC 73 ms
24,264 KB
testcase_38 AC 76 ms
23,376 KB
testcase_39 AC 74 ms
24,252 KB
testcase_40 AC 75 ms
23,820 KB
testcase_41 AC 72 ms
23,544 KB
testcase_42 AC 76 ms
23,712 KB
testcase_43 AC 74 ms
23,532 KB
testcase_44 AC 76 ms
23,244 KB
testcase_45 AC 71 ms
23,616 KB
testcase_46 AC 75 ms
23,904 KB
testcase_47 AC 70 ms
23,832 KB
testcase_48 AC 73 ms
23,904 KB
testcase_49 AC 69 ms
23,988 KB
testcase_50 AC 75 ms
23,532 KB
testcase_51 AC 74 ms
23,520 KB
testcase_52 AC 76 ms
23,892 KB
testcase_53 AC 72 ms
23,400 KB
testcase_54 AC 79 ms
23,712 KB
testcase_55 AC 72 ms
24,264 KB
testcase_56 AC 74 ms
23,904 KB
testcase_57 AC 71 ms
23,400 KB
testcase_58 AC 75 ms
23,532 KB
testcase_59 AC 77 ms
23,532 KB
testcase_60 AC 74 ms
23,640 KB
testcase_61 AC 75 ms
23,904 KB
testcase_62 AC 74 ms
23,556 KB
testcase_63 AC 71 ms
23,520 KB
testcase_64 AC 75 ms
23,820 KB
testcase_65 AC 81 ms
23,892 KB
testcase_66 AC 73 ms
23,892 KB
testcase_67 AC 78 ms
23,628 KB
testcase_68 AC 71 ms
23,700 KB
testcase_69 AC 74 ms
23,520 KB
testcase_70 AC 75 ms
24,012 KB
testcase_71 AC 72 ms
23,412 KB
testcase_72 AC 68 ms
23,880 KB
testcase_73 AC 73 ms
24,000 KB
testcase_74 AC 74 ms
23,364 KB
testcase_75 AC 73 ms
24,204 KB
testcase_76 AC 70 ms
23,724 KB
testcase_77 AC 76 ms
23,760 KB
testcase_78 AC 71 ms
24,276 KB
testcase_79 AC 71 ms
24,288 KB
testcase_80 AC 80 ms
23,256 KB
testcase_81 AC 76 ms
23,508 KB
testcase_82 AC 71 ms
23,364 KB
testcase_83 AC 75 ms
23,916 KB
testcase_84 AC 73 ms
24,000 KB
testcase_85 AC 33 ms
23,904 KB
testcase_86 AC 73 ms
24,216 KB
testcase_87 AC 75 ms
24,252 KB
testcase_88 AC 72 ms
23,820 KB
testcase_89 AC 75 ms
23,376 KB
testcase_90 AC 72 ms
23,520 KB
testcase_91 AC 79 ms
23,496 KB
testcase_92 AC 72 ms
23,412 KB
testcase_93 AC 75 ms
23,712 KB
testcase_94 AC 73 ms
24,000 KB
testcase_95 AC 74 ms
24,132 KB
testcase_96 AC 74 ms
23,256 KB
testcase_97 AC 70 ms
23,712 KB
testcase_98 AC 72 ms
24,024 KB
testcase_99 AC 75 ms
23,520 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <queue>
#include <vector>
#include <utility>
#include <random>
#include <chrono>
#include <algorithm>
#include <map>
#include <fstream>

using namespace std;
using pii = pair<int, int>;
using pll = pair<long long, long long>;

const bool LOCAL = false;
const bool RAND = false;
long long s = 0;
long long score = 0;
int ok_count = 0, try_count = 0;
int power = 100;

int turn = 1000;
vector<int> p(25);
int x = 12;

struct E {
    int h, p, x, turn;
    int damage;
};

vector<vector<E>> es(25);

struct Node {
    int x, power, turn, hp;
    char command;
};

bool operator<(const Node&l, const Node&r) {
    return ((double)l.power / l.turn) < ((double)r.power / r.turn);
}

mt19937 rnd(8);
uniform_int_distribution<> rng(0, 99);

struct Input {
    int h, p, x;
};
vector<vector<Input>> inputs(1000);

void read_input(int t) {
    if (LOCAL && RAND) {
        double mu = 7.5 + 0.15 * t;
        double sigma = 1.5 + 0.03 * t;
        for (int i = 0; i < 25; i++) {
            if (rng(rnd) <= p[i]) {
                normal_distribution<> hdist(mu, sigma);
                double h_ = hdist(rnd);
                int h = max(1, (int)floor(h_));
                normal_distribution<> pdist(0.8 * h_, pow(0.1 * h_, 2));
                double p_ = pdist(rnd);
                int p = max(0, (int)floor(p_));
                inputs[t].push_back(Input{h, p, i});
            }
        }

        for (auto &inpu : inputs[t]) {
            es[inpu.x].push_back(E{inpu.h, inpu.p, inpu.x, t, 0});
        }
    } else {
        int n;
        cin >> n;
        if (n == -1) exit(0);
        for (int i = 0; i < n; i++) {
            E e{0};
            e.turn = t;
            cin >> e.h >> e.p >> e.x;
            es[e.x].push_back(e);
        }
    }
}

void output(char c) {
    cout << c << endl;
    if (c == 'S') x = x;
    else if (c == 'L') x = (x - 1 + 25) % 25;
    else if (c == 'R') x = (x + 1) % 25;
}

vector<int> score_sum(25, 0);
vector<int> score_ave(25, 0);
vector<int> t_score(25, 0);

int main() {
    if (LOCAL) {
        for (int i = 0; i < 25; i++) {
            cin >> p[i];
        }
    }

    for (int i = 0; i < turn; i++) {
        for (int j = 0; j < 25; j++) {
            score_sum[j] = 0;
            score_ave[j] = 0;
            t_score[j] = 0;
            if (es[j].empty()) continue;
            if (j == x) {
                es[j][0].damage += power / 100;
                if (es[j][0].h <= es[j][0].damage) {
                    power += es[j][0].p;
                    score += es[j][0].h;
                }
            }
            if (i - es[j][0].turn >= 60 || es[j][0].h <= es[j][0].damage) {
                es[j].erase(es[j].begin());
            }

            for (auto &e : es[j]) {
                score_sum[j] += e.h;
            }

            if (es[j].size()) {
                score_ave[j] = score_sum[j] / es[j].size();
                t_score[j] = score_ave[j] * (1. + es[j].size() / 10);
            }
        }
        read_input(i);
        // rx[i] := (x + i) % 25のマスに移動するためのターン数
        // lx[i] := (x - i) % 25のマスに移動するためのターン数
        vector<int> rx(25, 100), lx(25, 100);
        rx[0] = lx[0] = 0;
        for (int i = 1; i < 25; i++) {
            int r_x = (x + i) % 25;
            int l_x = (x - i + 25) % 25;
            if (es[r_x].empty()) {
                rx[i] = rx[i - 1] + 1;
            } else {
                int ey = (i + rx[i - 1] - es[r_x].begin()->turn);
                if (ey >= 58) rx[i] = rx[i - 1] + 2;
                else rx[i] = rx[i - 1] + 1;
            }
            if (es[l_x].empty()) {
                lx[i] = lx[i - 1] + 1;
            } else {
                int ey = (i + lx[i - 1] - es[l_x].begin()->turn);
                if (ey >= 58) lx[i] = lx[i - 1] + 2;
                else lx[i] = lx[i - 1] + 1;
            }
        }
        vector<Node> ns;
        for (int k = 0; k < 25; k++) {
            int r_x = (k - x + 25) % 25;
            int l_x = (x - k + 25) % 25;
            if (es[k].empty()) continue;
            int j = 0;
            int min_dist = min(rx[r_x], lx[l_x]);
            while (min_dist + i - es[k][j].turn <= 0) {
                j++;
                if (j >= es[k].size()) break;
            }
            if (j >= es[k].size()) continue;
            int p = power / 100;
            int def_turn = (es[k][j].h - es[k][j].damage + p - 1) / p;
            if (i - es[k][j].turn + def_turn + min_dist >= 59) continue;
            char command = 'S';
            if (k != x) {
                if (rx[r_x] < lx[l_x]) command = 'R';
                else command = 'L';
                int nx;
                if (command == 'R') {
                    nx = (x + 1) % 25;
                } else {
                    nx = (x - 1 + 25) % 25;
                }
                if (!es[nx].empty()) {
                    // cout << "# " << i << " " << nx << " " << i - es[nx].begin()->turn << " " << es[nx].begin()->h << " " << es[nx].begin()->p << endl;
                    if (i - es[nx].begin()->turn >= 57) command = 'S';
                }
            }
            Node n;
            n.command = command;
            n.power = es[k][j].p;
            n.turn = def_turn + min_dist;
            if (i > 400) {
                n.power = es[k][j].h;
            }
            if (i > 600) {
                n.power = t_score[k];
                n.turn = (def_turn + min_dist);
            }
            if (n.turn == 0) n.turn = 1;
            n.hp = es[k][j].h - es[k][j].damage;
            n.x = k;
            ns.push_back(n);
        }
        sort(ns.begin(), ns.end());
        reverse(ns.begin(), ns.end());
        if (ns.empty()) {
            cout << "# empty" << endl;
            output('S');
        } else {
            cout << "# " << i << " " << ns[0].command << " " << x << " " << ns[0].x << " " << ns[0].power << " " << ns[0].hp << " " << ns[0].turn << endl;
            output(ns[0].command);
        }
    }
    if (LOCAL && RAND) {
        ofstream ofs("Visualizer_for_Windows/input.txt");
        ofs << p[0];
        for (int i = 1; i < 25; i++) {
            ofs << " " << p[i];
        }
        ofs << endl;
        for (int i = 0; i < 1000; i++) {
            ofs << inputs[i].size() << endl;
            for (auto &inp : inputs[i]) {
                ofs << inp.h << " " << inp.p << " " << inp.x << endl;
            }
        }
    }

    return 0;
}
0