結果
問題 | No.5017 Tool-assisted Shooting |
ユーザー | hari64 |
提出日時 | 2023-07-16 17:17:19 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 6,240 bytes |
コンパイル時間 | 2,524 ms |
コンパイル使用メモリ | 216,200 KB |
実行使用メモリ | 34,564 KB |
スコア | 47,570 |
平均クエリ数 | 21.17 |
最終ジャッジ日時 | 2023-07-16 17:17:53 |
合計ジャッジ時間 | 15,581 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | RE | - |
testcase_01 | RE | - |
testcase_02 | RE | - |
testcase_03 | RE | - |
testcase_04 | TLE | - |
testcase_05 | TLE | - |
testcase_06 | TLE | - |
testcase_07 | TLE | - |
testcase_08 | -- | - |
testcase_09 | -- | - |
testcase_10 | -- | - |
testcase_11 | -- | - |
testcase_12 | -- | - |
testcase_13 | -- | - |
testcase_14 | -- | - |
testcase_15 | -- | - |
testcase_16 | -- | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
testcase_22 | -- | - |
testcase_23 | -- | - |
testcase_24 | -- | - |
testcase_25 | -- | - |
testcase_26 | -- | - |
testcase_27 | -- | - |
testcase_28 | -- | - |
testcase_29 | -- | - |
testcase_30 | -- | - |
testcase_31 | -- | - |
testcase_32 | -- | - |
testcase_33 | -- | - |
testcase_34 | -- | - |
testcase_35 | -- | - |
testcase_36 | -- | - |
testcase_37 | -- | - |
testcase_38 | -- | - |
testcase_39 | -- | - |
testcase_40 | -- | - |
testcase_41 | -- | - |
testcase_42 | -- | - |
testcase_43 | -- | - |
testcase_44 | -- | - |
testcase_45 | -- | - |
testcase_46 | -- | - |
testcase_47 | -- | - |
testcase_48 | -- | - |
testcase_49 | -- | - |
testcase_50 | -- | - |
testcase_51 | -- | - |
testcase_52 | -- | - |
testcase_53 | -- | - |
testcase_54 | -- | - |
testcase_55 | -- | - |
testcase_56 | -- | - |
testcase_57 | -- | - |
testcase_58 | -- | - |
testcase_59 | -- | - |
testcase_60 | -- | - |
testcase_61 | -- | - |
testcase_62 | -- | - |
testcase_63 | -- | - |
testcase_64 | -- | - |
testcase_65 | -- | - |
testcase_66 | -- | - |
testcase_67 | -- | - |
testcase_68 | -- | - |
testcase_69 | -- | - |
testcase_70 | -- | - |
testcase_71 | -- | - |
testcase_72 | -- | - |
testcase_73 | -- | - |
testcase_74 | -- | - |
testcase_75 | -- | - |
testcase_76 | -- | - |
testcase_77 | -- | - |
testcase_78 | -- | - |
testcase_79 | -- | - |
testcase_80 | -- | - |
testcase_81 | -- | - |
testcase_82 | -- | - |
testcase_83 | -- | - |
testcase_84 | -- | - |
testcase_85 | -- | - |
testcase_86 | -- | - |
testcase_87 | -- | - |
testcase_88 | -- | - |
testcase_89 | -- | - |
testcase_90 | -- | - |
testcase_91 | -- | - |
testcase_92 | -- | - |
testcase_93 | -- | - |
testcase_94 | -- | - |
testcase_95 | -- | - |
testcase_96 | -- | - |
testcase_97 | -- | - |
testcase_98 | -- | - |
testcase_99 | -- | - |
ソースコード
#ifndef hari64 #include <bits/stdc++.h> // #pragma GCC target("avx2") // #pragma GCC optimize("O3") // #pragma GCC optimize("unroll-loops") #define debug(...) #else #include "util/viewer.hpp" #define debug(...) viewer::_debug(__LINE__, #__VA_ARGS__, __VA_ARGS__) #endif // clang-format off using namespace std; using ll = long long; using ld = long double; using pii = pair<int, int>; using pll = pair<ll, ll>; template <typename T> using vc = vector<T>; template <typename T> using vvc = vector<vc<T>>; template <typename T> using vvvc = vector<vvc<T>>; using vi = vc<int>; using vl = vc<ll>; using vpi = vc<pii>; using vpl = vc<pll>; #define ALL(x) begin(x), end(x) #define RALL(x) (x).rbegin(), (x).rend() constexpr int INF = 1001001001; constexpr long long INFll = 1001001001001001001; template <class T> bool chmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; } template <class T> bool chmin(T& a, const T& b) { return a > b ? a = b, 1 : 0; } // clang-format on struct Enemy { int h, p; int x, y; int initH; Enemy(int h, int p, int x) : h(h), p(p), x(x), y(59) { initH = h; } }; constexpr int H = 60; constexpr int W = 25; vvc<Enemy> GRID(W); int NOW_X; int LEVEL; int POWER_SUM; int SCORE; void update(vvc<Enemy>& g) { for (int x = 0; x < W; x++) { if (g[x].empty()) continue; for (auto& e : g[x]) { e.y--; } if (g[x].front().y == -1) { g[x].erase(g[x].begin()); } assert(g[x].empty() || g[x].front().y != -1); } } tuple<int, int, string> simulate(vector<int>& enemy) { string moves = ""; int score = 0; int score2 = 0; int nowX = NOW_X; int level = LEVEL; int powerSum = POWER_SUM; int totalTurn = 0; int enemyIndex = 0; auto grid = GRID; // for (int x = 0; x < W; x++) { // set<int> check; // for (auto& e : grid[x]) { // check.insert(e.y); // } // assert(check.size() == grid[x].size()); // } while (true) { totalTurn++; if (totalTurn > 1000) break; string move = "S"; if (nowX < enemy[enemyIndex]) { if (enemy[enemyIndex] - nowX < 12) { move = "R"; } else { move = "L"; } } else if (nowX > enemy[enemyIndex]) { if (nowX - enemy[enemyIndex] < 12) { move = "L"; } else { move = "R"; } } if (enemyIndex <= 1) { moves += move; } if (move == "L") nowX = (25 + nowX - 1) % 25; if (move == "R") nowX = (25 + nowX + 1) % 25; if (move == "S") nowX = nowX; if (grid[nowX].empty()) continue; if (grid[nowX].front().y == 1 || grid[nowX].front().y == 0) { return {-INF, -INF, "S"}; } grid[nowX].front().h -= level; score2 += grid[nowX].front().initH; if (grid[nowX].front().h <= 0) { score += grid[nowX].front().initH; powerSum += grid[nowX].front().p; level = 1 + powerSum / 100; grid[nowX].erase(grid[nowX].begin()); while (enemyIndex < int(enemy.size()) && grid[enemy[enemyIndex]].empty()) { enemyIndex++; } if (enemyIndex >= int(enemy.size())) break; } update(grid); } return {score / totalTurn, score2, moves}; } string solve() { int bestScore = -1; string bestMove = ""; if (LEVEL <= 100) { for (int e1 = 0; e1 < W; e1++) { if (GRID[e1].empty()) continue; vi enemies = {e1}; auto [score, _, move] = simulate(enemies); if (chmax(bestScore, score)) { bestMove = move; } } } else { for (int e1 = 0; e1 < W; e1++) { if (GRID[e1].empty()) continue; for (int e2 = 0; e2 < W; e2++) { if (GRID[e2].empty()) continue; for (int e3 = 0; e3 < W; e3++) { if (GRID[e3].empty()) continue; vi enemies = {e1, e2, e3}; auto [score, _, move] = simulate(enemies); if (chmax(bestScore, score)) { bestMove = move; } } } } } if (bestScore == -1) { debug("Game Over!"); } assert(!bestMove.empty()); // debug(bestScore, bestMove); return bestMove; } int main() { cin.tie(0); ios::sync_with_stdio(false); #ifdef hari64 for (int _ = 0; _ < W; _++) { int p; cin >> p; assert(1 <= p && p <= 8); } #endif NOW_X = 12; LEVEL = 1; POWER_SUM = 0; SCORE = 0; const int NUM_OF_TURNS = 1000; string moves = ""; vector<string> ans; for (int i = 0; i < NUM_OF_TURNS + 1; i++) { // debug(i); update(GRID); int n; cin >> n; if (n == -1) break; for (int i = 0; i < n; i++) { int h, p, x; cin >> h >> p >> x; assert(GRID[x].empty() || GRID[x].back().y < 59); GRID[x].push_back(Enemy(h, p, x)); } string s; if (i <= 5) { s = "S"; } else if (i <= 40) { if (moves.size() == 0) { moves = solve(); } s = string(1, moves[0]); moves.erase(moves.begin()); } else { s = string(1, solve()[0]); } #ifndef hari64 cout << s << endl; #endif ans.push_back(s); if (s == "L") NOW_X = (25 + NOW_X - 1) % 25; if (s == "R") NOW_X = (25 + NOW_X + 1) % 25; if (s == "S") NOW_X = NOW_X; if (GRID[NOW_X].empty()) continue; GRID[NOW_X].front().h -= LEVEL; if (GRID[NOW_X].front().h <= 0) { SCORE += GRID[NOW_X].front().initH; POWER_SUM += GRID[NOW_X].front().p; LEVEL = 1 + POWER_SUM / 100; GRID[NOW_X].erase(GRID[NOW_X].begin()); } } debug(SCORE, LEVEL, POWER_SUM, NOW_X); #ifdef hari64 for (auto s : ans) { cout << s << endl; } #endif return 0; }