結果
問題 | No.5003 物理好きクリッカー |
ユーザー | とばり |
提出日時 | 2018-12-06 07:54:06 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 9,314 ms / 10,000 ms |
コード長 | 2,877 bytes |
コンパイル時間 | 1,626 ms |
実行使用メモリ | 21,900 KB |
スコア | 4,454,573 |
平均クエリ数 | 10000.00 |
最終ジャッジ日時 | 2021-07-19 08:55:13 |
合計ジャッジ時間 | 311,205 ms |
ジャッジサーバーID (参考情報) |
judge10 / judge14 |
純コード判定しない問題か言語 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 9,305 ms
21,720 KB |
testcase_01 | AC | 9,311 ms
21,792 KB |
testcase_02 | AC | 9,307 ms
21,504 KB |
testcase_03 | AC | 9,310 ms
21,348 KB |
testcase_04 | AC | 9,313 ms
21,504 KB |
testcase_05 | AC | 9,310 ms
21,300 KB |
testcase_06 | AC | 9,314 ms
21,504 KB |
testcase_07 | AC | 9,308 ms
21,672 KB |
testcase_08 | AC | 9,304 ms
21,492 KB |
testcase_09 | AC | 9,308 ms
21,528 KB |
testcase_10 | AC | 9,307 ms
21,648 KB |
testcase_11 | AC | 9,304 ms
21,516 KB |
testcase_12 | AC | 9,311 ms
21,528 KB |
testcase_13 | AC | 9,305 ms
21,840 KB |
testcase_14 | AC | 9,306 ms
21,492 KB |
testcase_15 | AC | 9,308 ms
21,900 KB |
testcase_16 | AC | 9,310 ms
21,840 KB |
testcase_17 | AC | 9,310 ms
21,840 KB |
testcase_18 | AC | 9,300 ms
21,840 KB |
testcase_19 | AC | 9,303 ms
21,840 KB |
testcase_20 | AC | 9,310 ms
21,360 KB |
testcase_21 | AC | 9,302 ms
21,828 KB |
testcase_22 | AC | 9,310 ms
21,336 KB |
testcase_23 | AC | 9,308 ms
21,468 KB |
testcase_24 | AC | 9,305 ms
21,300 KB |
testcase_25 | AC | 9,306 ms
21,840 KB |
testcase_26 | AC | 9,312 ms
21,504 KB |
testcase_27 | AC | 9,301 ms
21,684 KB |
testcase_28 | AC | 9,305 ms
21,336 KB |
testcase_29 | AC | 9,304 ms
21,492 KB |
testcase_30 | AC | 9,305 ms
21,840 KB |
testcase_31 | AC | 9,307 ms
21,348 KB |
ソースコード
#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; std::string response; std::cin >> response; } return 0; }