結果
問題 | No.5003 物理好きクリッカー |
ユーザー | siman |
提出日時 | 2018-12-06 08:53:48 |
言語 | C++11 (gcc 11.4.0) |
結果 |
AC
|
実行時間 | 353 ms / 10,000 ms |
コード長 | 9,934 bytes |
コンパイル時間 | 664 ms |
実行使用メモリ | 21,960 KB |
スコア | 7,336,922 |
平均クエリ数 | 10000.00 |
最終ジャッジ日時 | 2021-07-19 08:55:40 |
合計ジャッジ時間 | 14,514 ms |
ジャッジサーバーID (参考情報) |
judge10 / judge14 |
純コード判定しない問題か言語 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 349 ms
21,684 KB |
testcase_01 | AC | 346 ms
21,372 KB |
testcase_02 | AC | 351 ms
21,468 KB |
testcase_03 | AC | 346 ms
21,528 KB |
testcase_04 | AC | 346 ms
21,504 KB |
testcase_05 | AC | 349 ms
21,648 KB |
testcase_06 | AC | 345 ms
21,504 KB |
testcase_07 | AC | 344 ms
21,864 KB |
testcase_08 | AC | 347 ms
21,840 KB |
testcase_09 | AC | 346 ms
21,888 KB |
testcase_10 | AC | 346 ms
21,840 KB |
testcase_11 | AC | 347 ms
21,144 KB |
testcase_12 | AC | 349 ms
21,480 KB |
testcase_13 | AC | 352 ms
21,492 KB |
testcase_14 | AC | 350 ms
21,852 KB |
testcase_15 | AC | 347 ms
21,360 KB |
testcase_16 | AC | 349 ms
21,300 KB |
testcase_17 | AC | 348 ms
21,468 KB |
testcase_18 | AC | 353 ms
21,360 KB |
testcase_19 | AC | 348 ms
21,492 KB |
testcase_20 | AC | 348 ms
21,480 KB |
testcase_21 | AC | 350 ms
21,504 KB |
testcase_22 | AC | 345 ms
21,516 KB |
testcase_23 | AC | 349 ms
21,888 KB |
testcase_24 | AC | 344 ms
21,888 KB |
testcase_25 | AC | 351 ms
21,528 KB |
testcase_26 | AC | 351 ms
21,864 KB |
testcase_27 | AC | 346 ms
21,660 KB |
testcase_28 | AC | 347 ms
21,480 KB |
testcase_29 | AC | 348 ms
21,324 KB |
testcase_30 | AC | 347 ms
21,816 KB |
testcase_31 | AC | 346 ms
21,852 KB |
ソースコード
#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 BUY_LILY = 5; const int BUY_FACTORY = 6; const int BUY_NEXT = 7; const int HAND = 1; const int LILY = 2; const int FACTORY = 3; const int CASINO = 4; const int GRIMOIRE = 5; const int BUY_OPERATIONS[6] = { NOTHING, BUY_LILY, BUY_FACTORY, NOTHING, NOTHING, NOTHING }; 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 factory_price[7][6]; 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; } } int prices[6] = {0, 150, 2000, 30000, 600000, 10000000}; for (int i = 1; i <= 5; i++) { int price = prices[i]; for (int j = 0; j < 6; j++) { factory_price[i][j] = price; price = ceil((6 * price) / 5); } } } vector <string> run(string events) { init(events); vector<int> actions; actions.push_back(ENHCLICK); actions.push_back(ENHCLICK); actions.push_back(BUY_LILY); actions.push_back(BUY_NEXT); actions.push_back(ENHCLICK); updateAnswer(actions); vector <string> answer = createAnswer(); 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; case BUY_LILY: answer.push_back("buy lily"); break; case BUY_FACTORY: answer.push_back("buy factory"); 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; int clickPoint; int price; int factoryCount[7] = {0, 0, 0, 0, 0, 0, 0}; int nextFactory; for (int i = 0; i < N; i++) { if (actions.size() <= index) break; clickPoint = clickPower; switch (actions[index]) { case ENHCLICK: updateCost = UPDATE_COST[CLICK][clickLevel]; if (bonus[i] == SALE) { updateCost = ceil(updateCost * 0.9) + 1; } if (cookie >= updateCost) { cookie -= updateCost; clickLevel++; clickPower *= 2; operations[i] = ENHCLICK; index++; clickPoint = 0; } break; case BUY_LILY: price = factory_price[LILY][factoryCount[LILY]]; if (bonus[i] == SALE) { price = ceil(price * 0.9) + 1; } if (cookie >= price) { cookie -= price; factoryCount[LILY]++; productivity += PRODUCTIVITY[LILY]; operations[i] = BUY_LILY; factoryLevel = max(factoryLevel, LILY); index++; clickPoint = 0; } break; case BUY_NEXT: nextFactory = factoryLevel + 1; price = factory_price[nextFactory][factoryCount[nextFactory]]; if (bonus[i] == SALE) { price = ceil(price * 0.9) + 1; } if (cookie >= price) { cookie -= price; factoryCount[nextFactory]++; productivity += PRODUCTIVITY[nextFactory]; operations[i] = BUY_OPERATIONS[nextFactory]; factoryLevel = max(factoryLevel, nextFactory); index++; clickPoint = 0; } break; } switch (bonus[i]) { case FEVER: cookie += 7 * (productivity + clickPoint); break; case BONUS: cookie += productivity + clickPoint; cookie += ceil(cookie * 0.01); break; default: cookie += productivity + clickPoint; break; } } } int calcScore() { int cookie = 0; int clickPower = 1; int clickLevel = 0; int updateCost; int price; int factoryCount[6] = {0, 0, 0, 0, 0, 0}; int productivity = 0; for (int i = 0; i < N; i++) { switch (operations[i]) { case NOTHING: break; case CLICK: if (bonus[i] == FEVER) { cookie += 7 * clickPower; } else { cookie += clickPower; } break; case ENHCLICK: updateCost = UPDATE_COST[CLICK][clickLevel]; if (bonus[i] == SALE) { updateCost = ceil(updateCost * 0.9) + 1; } assert(cookie >= updateCost); cookie -= updateCost; clickPower *= 2; clickLevel++; break; case BUY_LILY: price = factory_price[LILY][factoryCount[LILY]]; if (bonus[i] == SALE) { price = ceil(price * 0.9) + 1; } assert(cookie >= price); cookie -= price; factoryCount[LILY]++; productivity += PRODUCTIVITY[LILY]; break; case BUY_FACTORY: price = factory_price[FACTORY][factoryCount[FACTORY]]; if (bonus[i] == SALE) { price = ceil(price * 0.9) + 1; } assert(cookie >= price); cookie -= price; factoryCount[FACTORY]++; productivity += PRODUCTIVITY[FACTORY]; break; } switch (bonus[i]) { case FEVER: cookie += 7 * productivity; break; case BONUS: cookie += productivity; cookie += ceil(cookie * 0.01); break; default: cookie += productivity; break; } // fprintf(stderr, "%d: cookie = %d\n", i, cookie); } fprintf(stderr, "clickLevel = %d\n", clickLevel); return cookie; } }; int main() { int n; string s, res; CookieClicker cc; cin >> n; cin >> s; vector <string> answer = cc.run(s); for (int i = 0; i < N; i++) { cout << answer[i] << endl; cin >> res; cerr << res << endl; } int score = cc.calcScore(); // printf("Score = %d\n", score); return 0; }