結果

問題 No.5003 物理好きクリッカー
ユーザー とばりとばり
提出日時 2018-12-07 09:50:54
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,265 ms / 10,000 ms
コード長 5,818 bytes
コンパイル時間 2,172 ms
実行使用メモリ 21,996 KB
スコア 24,718,051,689
平均クエリ数 10000.00
最終ジャッジ日時 2021-07-19 09:03:41
合計ジャッジ時間 47,319 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
純コード判定しない問題か言語
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,168 ms
21,528 KB
testcase_01 AC 1,220 ms
21,516 KB
testcase_02 AC 1,220 ms
21,360 KB
testcase_03 AC 1,197 ms
21,516 KB
testcase_04 AC 1,214 ms
21,852 KB
testcase_05 AC 1,179 ms
21,864 KB
testcase_06 AC 1,230 ms
21,336 KB
testcase_07 AC 1,261 ms
21,852 KB
testcase_08 AC 1,225 ms
21,852 KB
testcase_09 AC 1,256 ms
21,372 KB
testcase_10 AC 1,187 ms
21,480 KB
testcase_11 AC 1,201 ms
21,492 KB
testcase_12 AC 1,158 ms
21,900 KB
testcase_13 AC 1,192 ms
21,672 KB
testcase_14 AC 1,194 ms
21,840 KB
testcase_15 AC 1,171 ms
21,360 KB
testcase_16 AC 1,203 ms
21,840 KB
testcase_17 AC 1,177 ms
21,540 KB
testcase_18 AC 1,177 ms
21,912 KB
testcase_19 AC 1,235 ms
21,516 KB
testcase_20 AC 1,239 ms
21,852 KB
testcase_21 AC 1,212 ms
21,852 KB
testcase_22 AC 1,165 ms
21,864 KB
testcase_23 AC 1,220 ms
21,360 KB
testcase_24 AC 1,192 ms
21,300 KB
testcase_25 AC 1,148 ms
21,912 KB
testcase_26 AC 1,209 ms
21,348 KB
testcase_27 AC 1,150 ms
21,864 KB
testcase_28 AC 1,164 ms
21,348 KB
testcase_29 AC 1,183 ms
21,864 KB
testcase_30 AC 1,196 ms
21,840 KB
testcase_31 AC 1,265 ms
21,348 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: メンバ関数 ‘State State::sell(Equipment)’ 内:
main.cpp:101:5: 警告: 非 void を戻す関数内に return 文がありません [-Wreturn-type]
  101 |     }
      |     ^

ソースコード

diff #

#include <bits/stdc++.h>

#define DEBUG

const int64_t inf = (1LL << 40);

enum Equipment
{
    HAND,
    LILY,
    FACTORY,
    CASINO,
    GRIMOIRE
};

const Equipment equipments[] = {HAND, LILY, FACTORY, CASINO, GRIMOIRE};
const std::string names[] = {"hand", "lily", "factory", "casino", "grimoire"};

const int64_t baseProductivities[] = {1, 10, 120, 2000, 25000};
const int64_t basePrices[] = {150, 2000, 30000, 600000, 10000000};

int64_t productivity(Equipment e, int level)
{
    return (baseProductivities[e] << level);
}

int64_t reinforcePrice(Equipment e, int level)
{
    int64_t res = basePrices[e];
    for (int i = 0; i <= level; i++)
    {
        res *= 10;
    }
    return res;
}

int64_t buyPrice(Equipment e, int num)
{
    int64_t res = basePrices[e];
    for (int i = 0; i < num; i++)
    {
        res = (6 * res + 4) / 5;
    }
    return res;
}

struct State
{
    int turn_;
    int64_t score_;
    int levelClick_;
    std::array<int, 5> numEquipment_;
    std::array<int, 5> levelEquipment_;

    State(): turn_{0}, score_{0}, levelClick_{0}
    {
        numEquipment_.fill(0);
        levelEquipment_.fill(0);
    }

    void produce()
    {
        if (score_ < 0) return;

        for (auto e : equipments)
        {
            score_ += numEquipment_[e] * productivity(e, levelEquipment_[e]);
        }
    }

    void update()
    {
        if (score_ < 0)
        {
            score_ = -inf;
        }
        produce();
        turn_++;
    }

    State click() const
    {
        State next = *this;
        next.score_ += (1LL << levelClick_);
        next.update();
        return next;
    }

    State buy(Equipment e) const
    {
        State next = *this;
        next.score_ -= buyPrice(e, numEquipment_[e]);
        next.numEquipment_[e]++;
        next.update();
        return next;
    }

    // 未実装
    State sell(Equipment e)
    {
    }

    State reinforce(Equipment e) const
    {
        State next = *this;
        next.score_ -= reinforcePrice(e, levelEquipment_[e]);
        next.levelEquipment_[e]++;
        next.update();
        return next;
    }

    State enhclick() const
    {
        State next = *this;
        int64_t cost = 15;
        for (int i = 0; i < levelClick_; i++)
        {
            cost *= 10;
        }
        next.score_ -= cost;
        next.levelClick_++;
        next.update();
        return next;
    }

    int64_t expectScore(int numTurn)
    {
        if (score_ < 0) return -inf;

        int64_t add = (1LL << levelClick_);
        for (auto e : equipments)
        {
            add += numEquipment_[e] * productivity(e, levelEquipment_[e]);
        }
#ifdef DEBUG
        std::cerr << "add: " << add << std::endl;
#endif
        return score_ + numTurn * add;
    }
};


std::pair<State, std::string> findNextAction(const State& current, int numTurn)
{
    int64_t bestScore = 0;
    std::string action = "click";
    State next = current;

    // click
    {
        State click = current.click();
        int64_t score = click.expectScore(numTurn - 1);
        if (score > bestScore)
        {
            next = click;
            bestScore = score;
            action = "click";
        }
    }
    // enhclick
    {
        State enhclick = current.enhclick();
        int64_t score = enhclick.expectScore(numTurn - 1);
        if (score > bestScore)
        {
            next = enhclick;
            bestScore = score;
            action = "enhclick";
        }
    }
    // buy
    {
        for (auto e : equipments)
        {
            State buy = current.buy(e);
            int64_t score = buy.expectScore(numTurn - 1);

            if (score > bestScore)
            {
                next = buy;
                bestScore = score;
                action = "buy " + names[e];
            }
        }
    }
    // reinforce
    {
        for (auto e : equipments)
        {
            State reinforce = current.reinforce(e);
            int64_t score = reinforce.expectScore(numTurn - 1);

            if (score > bestScore)
            {
                next = reinforce;
                bestScore = score;
                action = "reinforce " + names[e];
            }
        }
    }
    return {next, action};
}

int main()
{
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);

    int n;
    std::cin >> n;

    std::string s;
    std::cin >> s;

    State current{};

    for (int i = 0; i < n; i++)
    {
        if (current.numEquipment_[GRIMOIRE] >= n - i)
        {
            std::cout << "sell " << names[GRIMOIRE] << std::endl;

            current.numEquipment_[GRIMOIRE]--;
            std::string response;
            std::cin >> response;

            continue;
        }

        auto result = findNextAction(current, n - i);

        std::cout << result.second << std::endl;

        std::string response;
        std::cin >> response;

        assert(response == "ok");

        current = result.first;

#ifdef DEBUG
        std::cerr << "====== " << i << " ======" << std::endl;
        std::cerr << "[Score] " << current.expectScore(0) << std::endl;
        for (auto e : equipments)
        {
            std::cerr << "[" << names[e] << "] " << current.numEquipment_[e]
                    << ", " << current.levelEquipment_[e] << std::endl;
            std::cerr << "nextBuy " << buyPrice(e, current.numEquipment_[e]) << std::endl;
            std::cerr << "nextReinforce " << reinforcePrice(e, current.levelEquipment_[e]) << std::endl;
        }
#endif
    }

#ifdef DEBUG
    std::cerr << "[Score] " << current.expectScore(0) << std::endl;
    for (auto e : equipments)
    {
        std::cerr << "[" << names[e] << "] " << current.numEquipment_[e]
                  << ", " << current.levelEquipment_[e] << std::endl;
    }
#endif

    return 0;
}
0