結果

問題 No.5003 物理好きクリッカー
ユーザー simansiman
提出日時 2018-12-06 00:20:06
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 6,019 bytes
コンパイル時間 554 ms
実行使用メモリ 21,936 KB
スコア 1,667,459
平均クエリ数 10000.00
最終ジャッジ日時 2021-07-19 08:49:13
合計ジャッジ時間 4,006 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 41 ms
21,360 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 40 ms
21,372 KB
testcase_05 AC 40 ms
21,360 KB
testcase_06 AC 41 ms
21,684 KB
testcase_07 AC 41 ms
21,864 KB
testcase_08 WA -
testcase_09 AC 41 ms
21,804 KB
testcase_10 AC 42 ms
21,684 KB
testcase_11 AC 40 ms
21,864 KB
testcase_12 AC 43 ms
21,876 KB
testcase_13 AC 41 ms
21,504 KB
testcase_14 AC 40 ms
21,840 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 41 ms
21,876 KB
testcase_19 AC 42 ms
21,516 KB
testcase_20 WA -
testcase_21 AC 41 ms
21,876 KB
testcase_22 AC 41 ms
21,840 KB
testcase_23 AC 35 ms
21,888 KB
testcase_24 AC 42 ms
21,204 KB
testcase_25 AC 41 ms
21,528 KB
testcase_26 WA -
testcase_27 AC 40 ms
21,876 KB
testcase_28 AC 41 ms
21,936 KB
testcase_29 AC 40 ms
21,360 KB
testcase_30 AC 40 ms
21,720 KB
testcase_31 AC 40 ms
21,876 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cassert>
#include <cmath>
#include <iostream>
#include <vector>
#include <string.h>

using namespace std;

const int N = 10000;

const int NOTHING = -1;
const int CLICK = 0;
const int BUY = 1;
const int SELL = 2;
const int REINFORCE = 3;
const int ENHCLICK = 4;

const int HAND = 1;
const int LILY = 2;
const int FACTORY = 3;
const int CASINO = 4;
const int GRIMOIRE = 5;

const int BONUS = 1;
const int FEVER = 2;
const int SALE = 3;

const int PRODUCTIVITY[6] = {
        1,
        1,
        10,
        120,
        2000,
        25000
};

const int UPDATE_COST[6][6] = {
        {
                15,
                150,
                1500,
                15000,
                150000,
                1500000
        },
        {
                150,
                1500,
                15000,
                150000,
                1500000,
                15000000
        },
        {
                2000,
                20000,
                200000,
                2000000,
                20000000,
                200000000,
        },
        {
                15,
                150,
                1500,
                15000,
                150000,
                1500000
        },
        {
                15,
                150,
                1500,
                15000,
                150000,
                1500000
        },
        {
                15,
                150,
                1500,
                15000,
                150000,
                1500000
        },
};

int operations[N];
int bonus[N + 21];

class CookieClicker {
public:

    void init(string events) {
        memset(operations, CLICK, sizeof(operations));
        memset(bonus, NOTHING, sizeof(bonus));

        for (int i = 0; i < N; i++) {
            switch (events[i]) {
                case 'B':
                    bonus[i] = BONUS;
                    break;
                case 'F':
                    for (int j = i + 1; j <= i + 20; j++) {
                        bonus[j] = FEVER;
                    }
                    break;
                case 'S':
                    bonus[i + 1] = SALE;
                    break;
            }
        }
    }

    vector <string> run(string events) {
        init(events);

        vector<int> actions;
        actions.push_back(ENHCLICK);
        actions.push_back(ENHCLICK);
        actions.push_back(ENHCLICK);
        actions.push_back(ENHCLICK);
        actions.push_back(ENHCLICK);
        updateAnswer(actions);

        vector <string> answer = createAnswer();
        int score = calcScore();

        // printf("Score = %d\n", score);

        return answer;
    }

    vector <string> createAnswer() {
        vector <string> answer;

        for (int i = 0; i < N; i++) {
            switch (operations[i]) {
                case NOTHING:
                    answer.push_back("nothing");
                    break;
                case CLICK:
                    answer.push_back("click");
                    break;
                case BUY:
                    answer.push_back("buy");
                    break;
                case SELL:
                    break;
                case REINFORCE:
                    break;
                case ENHCLICK:
                    answer.push_back("enhclick");
                    break;
                default:
                    assert(false);
            }
        }

        return answer;
    }

    void updateAnswer(vector<int> actions) {
        int index = 0;
        int clickLevel = 0;
        int factoryLevel = 0;
        int cookie = 0;
        int productivity = 0;
        int clickPower = 1;
        int updateCost;

        for (int i = 0; i < N; i++) {
            if (actions.size() <= index) break;

            switch (actions[index]) {
                case ENHCLICK:
                    updateCost = UPDATE_COST[CLICK][clickLevel];
                    if (bonus[i] == SALE) {
                        updateCost = ceil(updateCost * 0.9);
                    }

                    if (cookie >= updateCost) {
                        cookie -= updateCost;
                        clickLevel++;
                        clickPower *= 2;
                        operations[i] = ENHCLICK;
                        index++;
                        continue;
                    }
                    break;
            }

            switch (bonus[i]) {
                case FEVER:
                    cookie += 7 * (productivity + clickPower);
                    break;
                case BONUS:
                    cookie += productivity + clickPower;
                    cookie += ceil(cookie * 0.01);
                    break;
                default:
                    cookie += productivity + clickPower;
                    break;
            }
        }
    }

    int calcScore() {
        int score = 0;
        int clickPower = 1;
        int clickLevel = 0;

        for (int i = 0; i < N; i++) {
            switch (operations[i]) {
                case NOTHING:
                    break;
                case CLICK:
                    if (bonus[i] == FEVER) {
                        score += 7 * clickPower;
                    } else {
                        score += clickPower;
                    }
                    break;
                case ENHCLICK:
                    score -= UPDATE_COST[CLICK][clickLevel];
                    clickPower *= 2;
                    clickLevel++;
                    break;
            }

            if (bonus[i] == BONUS) {
                score += ceil(score * 0.01);
            }

            // fprintf(stderr, "%d: cookie = %d\n", i, score);
        }

        fprintf(stderr, "clickLevel = %d\n", clickLevel);

        return score;
    }
};

int main() {
    int n;
    string s;
    CookieClicker cc;

    cin >> n;
    cin >> s;

    vector <string> answer = cc.run(s);

    for (int i = 0; i < N; i++) {
        cout << answer[i] << endl;
    }

    return 0;
}
0