結果
| 問題 |
No.5003 物理好きクリッカー
|
| コンテスト | |
| ユーザー |
とばり
|
| 提出日時 | 2018-12-07 09:50:54 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.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 |
| 純コード判定しない問題か言語 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 32 |
コンパイルメッセージ
main.cpp: メンバ関数 ‘State State::sell(Equipment)’ 内:
main.cpp:101:5: 警告: 非 void を戻す関数内に return 文がありません [-Wreturn-type]
101 | }
| ^
ソースコード
#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;
}
とばり