結果
問題 | No.5003 物理好きクリッカー |
ユーザー | とばり |
提出日時 | 2018-12-06 07:41:24 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,869 bytes |
コンパイル時間 | 1,988 ms |
実行使用メモリ | 21,996 KB |
スコア | 2,598,625 |
平均クエリ数 | 10000.00 |
最終ジャッジ日時 | 2021-07-19 08:55:04 |
合計ジャッジ時間 | 302,451 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | AC | 9,031 ms
21,996 KB |
testcase_02 | AC | 9,033 ms
21,360 KB |
testcase_03 | AC | 9,036 ms
21,888 KB |
testcase_04 | AC | 9,033 ms
21,360 KB |
testcase_05 | AC | 9,034 ms
21,864 KB |
testcase_06 | WA | - |
testcase_07 | AC | 9,031 ms
21,432 KB |
testcase_08 | AC | 9,036 ms
21,864 KB |
testcase_09 | WA | - |
testcase_10 | AC | 9,030 ms
21,996 KB |
testcase_11 | WA | - |
testcase_12 | AC | 9,030 ms
21,852 KB |
testcase_13 | WA | - |
testcase_14 | AC | 9,029 ms
21,924 KB |
testcase_15 | AC | 9,033 ms
21,924 KB |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | AC | 9,034 ms
21,696 KB |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | AC | 9,030 ms
21,876 KB |
testcase_22 | AC | 9,031 ms
21,924 KB |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | AC | 9,029 ms
21,516 KB |
testcase_26 | AC | 9,030 ms
21,876 KB |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | AC | 9,035 ms
21,360 KB |
testcase_30 | AC | 9,036 ms
21,900 KB |
testcase_31 | WA | - |
ソースコード
#include <bits/stdc++.h> // #define DEBUG struct MSecTimer { std::chrono::system_clock::time_point from_; MSecTimer() { restart(); } void restart() { from_ = std::chrono::system_clock::now(); } int64_t elapsed() { auto now = std::chrono::system_clock::now(); return std::chrono::duration_cast<std::chrono::milliseconds>(now - from_).count(); } }; int randInt(int n) { static std::random_device rnd; static std::mt19937 mt(rnd()); return mt() % n; } enum Action { CLICK, ENHCLICK }; const int64_t inf = (1LL << 50); int64_t getScore(const std::vector<Action>& seq) { int levelClick = 0, costClick = 15; int64_t score = 0; for (int act : seq) { switch (act) { case CLICK: score += (1LL << levelClick); break; case ENHCLICK: score -= costClick; levelClick++; costClick *= 10; break; } if (score < 0) return -inf; } return score; } std::vector<Action> generateNextState(const std::vector<Action>& current) { auto next = current; int i = randInt(current.size()); if (next[i] == CLICK) next[i] = ENHCLICK; else next[i] = CLICK; return next; } std::vector<Action> SA(int numTurn) { #ifdef DEBUG const int64_t timeLimit = 1000; // 9sec #else const int64_t timeLimit = 9000; // 9sec #endif std::vector<Action> current(numTurn, CLICK); int64_t currentScore = getScore(current); auto best = current; int64_t bestScore = currentScore; MSecTimer timer; while (timer.elapsed() < timeLimit) { #ifdef DEBUG std::cerr << "elapsed: " << timer.elapsed() << " current: " << currentScore << " best: " << bestScore << std::endl; #endif // 次の状態を生成 auto next = generateNextState(current); int64_t nextScore = getScore(next); int64_t t = timer.elapsed(), r = 10000; bool forceNext = r * (timeLimit - t) > timeLimit * randInt(r); if (nextScore > currentScore or (forceNext and currentScore > 0)) { currentScore = nextScore; current = next; } if (currentScore > bestScore) { bestScore = currentScore; best = current; } } return best; } int main() { std::cin.tie(nullptr); std::ios::sync_with_stdio(false); int n; std::cin >> n; std::string s; std::cin >> s; auto ans = SA(n); for (int i = 0; i < n; i++) { if (ans[i] == ENHCLICK) std::cout << "enhclick" << std::endl; else std::cout << "click" << std::endl; int response; std::cin >> response; } return 0; }