結果
問題 | No.5017 Tool-assisted Shooting |
ユーザー | n-inja |
提出日時 | 2023-07-16 17:11:22 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 31 ms / 2,000 ms |
コード長 | 4,590 bytes |
コンパイル時間 | 1,230 ms |
コンパイル使用メモリ | 111,720 KB |
実行使用メモリ | 24,408 KB |
スコア | 1,950 |
平均クエリ数 | 103.62 |
最終ジャッジ日時 | 2023-07-16 17:11:32 |
合計ジャッジ時間 | 8,766 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge14 |
純コード判定しない問題か言語 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 31 ms
23,652 KB |
testcase_01 | AC | 28 ms
23,640 KB |
testcase_02 | AC | 27 ms
24,024 KB |
testcase_03 | AC | 28 ms
24,396 KB |
testcase_04 | AC | 28 ms
23,544 KB |
testcase_05 | AC | 28 ms
24,288 KB |
testcase_06 | AC | 28 ms
24,384 KB |
testcase_07 | AC | 28 ms
23,640 KB |
testcase_08 | AC | 27 ms
24,384 KB |
testcase_09 | AC | 27 ms
24,276 KB |
testcase_10 | AC | 28 ms
23,652 KB |
testcase_11 | AC | 28 ms
23,640 KB |
testcase_12 | AC | 28 ms
23,424 KB |
testcase_13 | AC | 27 ms
23,856 KB |
testcase_14 | AC | 27 ms
24,024 KB |
testcase_15 | AC | 27 ms
23,424 KB |
testcase_16 | AC | 28 ms
24,060 KB |
testcase_17 | AC | 28 ms
24,024 KB |
testcase_18 | AC | 26 ms
23,424 KB |
testcase_19 | AC | 27 ms
23,844 KB |
testcase_20 | AC | 28 ms
23,412 KB |
testcase_21 | AC | 27 ms
23,844 KB |
testcase_22 | AC | 28 ms
23,544 KB |
testcase_23 | AC | 28 ms
24,072 KB |
testcase_24 | AC | 28 ms
23,640 KB |
testcase_25 | AC | 27 ms
23,544 KB |
testcase_26 | AC | 28 ms
23,652 KB |
testcase_27 | AC | 27 ms
23,424 KB |
testcase_28 | AC | 27 ms
23,436 KB |
testcase_29 | AC | 27 ms
23,652 KB |
testcase_30 | AC | 29 ms
23,844 KB |
testcase_31 | AC | 27 ms
24,072 KB |
testcase_32 | AC | 28 ms
23,436 KB |
testcase_33 | AC | 29 ms
23,652 KB |
testcase_34 | AC | 28 ms
24,036 KB |
testcase_35 | AC | 28 ms
23,544 KB |
testcase_36 | AC | 28 ms
24,372 KB |
testcase_37 | AC | 27 ms
23,400 KB |
testcase_38 | AC | 27 ms
23,832 KB |
testcase_39 | AC | 28 ms
23,520 KB |
testcase_40 | AC | 28 ms
24,072 KB |
testcase_41 | AC | 27 ms
23,544 KB |
testcase_42 | AC | 29 ms
23,664 KB |
testcase_43 | AC | 28 ms
24,276 KB |
testcase_44 | AC | 27 ms
24,024 KB |
testcase_45 | AC | 29 ms
23,544 KB |
testcase_46 | AC | 27 ms
23,544 KB |
testcase_47 | AC | 28 ms
24,336 KB |
testcase_48 | AC | 29 ms
23,676 KB |
testcase_49 | AC | 28 ms
23,652 KB |
testcase_50 | AC | 29 ms
23,388 KB |
testcase_51 | AC | 28 ms
23,856 KB |
testcase_52 | AC | 27 ms
24,384 KB |
testcase_53 | AC | 28 ms
23,676 KB |
testcase_54 | AC | 28 ms
23,676 KB |
testcase_55 | AC | 28 ms
24,060 KB |
testcase_56 | AC | 29 ms
24,036 KB |
testcase_57 | AC | 28 ms
24,060 KB |
testcase_58 | AC | 27 ms
23,544 KB |
testcase_59 | AC | 27 ms
23,664 KB |
testcase_60 | AC | 29 ms
24,408 KB |
testcase_61 | AC | 27 ms
23,640 KB |
testcase_62 | AC | 28 ms
23,424 KB |
testcase_63 | AC | 27 ms
23,412 KB |
testcase_64 | AC | 27 ms
23,844 KB |
testcase_65 | AC | 28 ms
23,544 KB |
testcase_66 | AC | 29 ms
24,276 KB |
testcase_67 | AC | 28 ms
24,048 KB |
testcase_68 | AC | 29 ms
23,424 KB |
testcase_69 | AC | 28 ms
23,388 KB |
testcase_70 | AC | 27 ms
23,652 KB |
testcase_71 | AC | 28 ms
23,544 KB |
testcase_72 | AC | 30 ms
24,072 KB |
testcase_73 | AC | 27 ms
24,060 KB |
testcase_74 | AC | 27 ms
23,388 KB |
testcase_75 | AC | 28 ms
23,664 KB |
testcase_76 | AC | 28 ms
24,012 KB |
testcase_77 | AC | 29 ms
23,376 KB |
testcase_78 | AC | 28 ms
23,424 KB |
testcase_79 | AC | 31 ms
23,652 KB |
testcase_80 | AC | 28 ms
23,832 KB |
testcase_81 | AC | 28 ms
23,556 KB |
testcase_82 | AC | 28 ms
23,832 KB |
testcase_83 | AC | 27 ms
23,844 KB |
testcase_84 | AC | 27 ms
23,388 KB |
testcase_85 | AC | 28 ms
24,036 KB |
testcase_86 | AC | 27 ms
24,276 KB |
testcase_87 | AC | 27 ms
23,640 KB |
testcase_88 | AC | 28 ms
23,532 KB |
testcase_89 | AC | 27 ms
23,388 KB |
testcase_90 | AC | 28 ms
23,652 KB |
testcase_91 | AC | 28 ms
24,396 KB |
testcase_92 | AC | 28 ms
24,372 KB |
testcase_93 | AC | 28 ms
23,436 KB |
testcase_94 | AC | 28 ms
23,436 KB |
testcase_95 | AC | 28 ms
23,832 KB |
testcase_96 | AC | 27 ms
23,652 KB |
testcase_97 | AC | 28 ms
23,424 KB |
testcase_98 | AC | 27 ms
23,676 KB |
testcase_99 | AC | 27 ms
23,664 KB |
ソースコード
#include <iostream> #include <queue> #include <vector> #include <utility> #include <random> #include <chrono> #include <algorithm> #include <map> using namespace std; using pii = pair<int, int>; using pll = pair<long long, long long>; const bool LOCAL = false; long long s = 0; long long score = 0; int ok_count = 0, try_count = 0; int power = 100; int turn = 1000; vector<int> p(25); int x = 12; struct E { int h, p, x, turn; int damage; }; vector<vector<E>> es(25); struct Node { int x, power, turn, hp; char command; }; bool operator<(const Node&l, const Node&r) { return ((double)l.power / l.turn) < ((double)r.power / r.turn); } void read_input(int t) { int n; cin >> n; if (n == -1) exit(0); for (int i = 0; i < n; i++) { E e; e.turn = t; cin >> e.h >> e.p >> e.x; es[e.x].push_back(e); } } void output(char c) { cout << c << endl; if (c == 'S') x = x; else if (c == 'L') x = (x - 1 + 25) % 25; else if (c == 'R') x = (x + 1) % 25; } int main() { if (LOCAL) { for (int i = 0; i < 25; i++) { cin >> p[i]; } } for (int i = 0; i < turn; i++) { for (int j = 0; j < 25; j++) { if (es[j].empty()) continue; if (j == x) { es[j][0].damage += power / 100; if (es[j][0].h <= es[j][0].damage) { power += es[j][0].p; score += es[j][0].h; } } if (i - es[j][0].turn >= 60 || es[j][0].h <= es[j][0].damage) { es[j].erase(es[j].begin()); } } read_input(i); // rx[i] := (x + i) % 25のマスに移動するためのターン数 // lx[i] := (x - i) % 25のマスに移動するためのターン数 vector<int> rx(25, 100), lx(25, 100); rx[0] = lx[0] = 0; for (int i = 1; i < 25; i++) { int r_x = (x + i) % 25; int l_x = (x - i + 25) % 25; if (es[r_x].empty()) { rx[i] = rx[i - 1] + 1; } else { int ey = (i + rx[i - 1] - es[r_x].begin()->turn); if (ey >= 58) rx[i] = rx[i - 1] + 2; else rx[i] = rx[i - 1] + 1; } if (es[l_x].empty()) { lx[i] = lx[i - 1] + 1; } else { int ey = (i + lx[i - 1] - es[l_x].begin()->turn); if (ey >= 58) lx[i] = lx[i - 1] + 2; else lx[i] = lx[i - 1] + 1; } } vector<Node> ns; for (int k = 0; k < 25; k++) { int r_x = (k - x + 25) % 25; int l_x = (x - k + 25) % 25; if (es[k].empty()) continue; int j = 0; int min_dist = min(rx[r_x], lx[l_x]); while (min_dist + i - es[k][j].turn <= 0) { j++; if (j >= es[k].size()) break; } if (j >= es[k].size()) continue; int p = power / 100; int def_turn = (es[k][j].h - es[k][j].damage + p - 1) / p; if (i - es[k][j].turn + def_turn + min_dist >= 59) continue; char command = 'S'; if (k != x) { if (rx[r_x] < lx[l_x]) command = 'R'; else command = 'L'; int nx; if (command == 'R') { nx = (x + 1) % 25; } else { nx = (x - 1 + 25) % 25; } if (!es[nx].empty()) { // cout << "# " << i << " " << nx << " " << i - es[nx].begin()->turn << " " << es[nx].begin()->h << " " << es[nx].begin()->p << endl; if (i - es[nx].begin()->turn >= 57) command = 'S'; } } Node n; n.command = command; n.power = es[k][j].p; if (i > 500) { n.power = es[k][j].h; } n.turn = def_turn + min_dist; if (n.turn == 0) n.turn = 1; n.hp = es[k][j].h - es[k][j].damage; n.x = k; ns.push_back(n); } sort(ns.begin(), ns.end()); reverse(ns.begin(), ns.end()); if (ns.empty()) { cout << "# empty" << endl; output('S'); } else { // cout << "# " << i << " " << ns[0].command << " " << x << " " << ns[0].x << " " << ns[0].power << " " << ns[0].hp << " " << ns[0].turn << endl; output(ns[0].command); } } return 0; }