結果
問題 | No.5017 Tool-assisted Shooting |
ユーザー | Shun_PI |
提出日時 | 2023-07-16 17:50:11 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 1,156 ms / 2,000 ms |
コード長 | 5,668 bytes |
コンパイル時間 | 3,394 ms |
コンパイル使用メモリ | 210,288 KB |
実行使用メモリ | 24,396 KB |
スコア | 3,956,744 |
平均クエリ数 | 1000.00 |
最終ジャッジ日時 | 2023-07-16 17:51:44 |
合計ジャッジ時間 | 93,007 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge11 |
純コード判定しない問題か言語 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 835 ms
23,664 KB |
testcase_01 | AC | 908 ms
23,448 KB |
testcase_02 | AC | 684 ms
24,396 KB |
testcase_03 | AC | 840 ms
23,388 KB |
testcase_04 | AC | 694 ms
23,388 KB |
testcase_05 | AC | 779 ms
23,928 KB |
testcase_06 | AC | 800 ms
23,640 KB |
testcase_07 | AC | 869 ms
24,276 KB |
testcase_08 | AC | 737 ms
24,252 KB |
testcase_09 | AC | 757 ms
24,324 KB |
testcase_10 | AC | 862 ms
23,748 KB |
testcase_11 | AC | 744 ms
24,324 KB |
testcase_12 | AC | 807 ms
23,436 KB |
testcase_13 | AC | 850 ms
23,544 KB |
testcase_14 | AC | 915 ms
23,628 KB |
testcase_15 | AC | 827 ms
24,228 KB |
testcase_16 | AC | 742 ms
23,652 KB |
testcase_17 | AC | 877 ms
24,288 KB |
testcase_18 | AC | 841 ms
23,532 KB |
testcase_19 | AC | 849 ms
23,844 KB |
testcase_20 | AC | 858 ms
23,928 KB |
testcase_21 | AC | 895 ms
23,640 KB |
testcase_22 | AC | 705 ms
23,640 KB |
testcase_23 | AC | 732 ms
23,292 KB |
testcase_24 | AC | 903 ms
23,568 KB |
testcase_25 | AC | 916 ms
23,928 KB |
testcase_26 | AC | 770 ms
23,604 KB |
testcase_27 | AC | 790 ms
24,048 KB |
testcase_28 | AC | 919 ms
23,844 KB |
testcase_29 | AC | 693 ms
23,328 KB |
testcase_30 | AC | 691 ms
24,264 KB |
testcase_31 | AC | 742 ms
24,300 KB |
testcase_32 | AC | 893 ms
23,388 KB |
testcase_33 | AC | 963 ms
23,844 KB |
testcase_34 | AC | 778 ms
23,676 KB |
testcase_35 | AC | 837 ms
23,532 KB |
testcase_36 | AC | 749 ms
24,288 KB |
testcase_37 | AC | 876 ms
23,316 KB |
testcase_38 | AC | 868 ms
24,072 KB |
testcase_39 | AC | 840 ms
23,544 KB |
testcase_40 | AC | 843 ms
23,400 KB |
testcase_41 | AC | 773 ms
23,676 KB |
testcase_42 | AC | 905 ms
23,436 KB |
testcase_43 | AC | 821 ms
23,292 KB |
testcase_44 | AC | 902 ms
23,664 KB |
testcase_45 | AC | 871 ms
23,424 KB |
testcase_46 | AC | 897 ms
23,448 KB |
testcase_47 | AC | 721 ms
23,940 KB |
testcase_48 | AC | 930 ms
23,376 KB |
testcase_49 | AC | 829 ms
24,300 KB |
testcase_50 | AC | 815 ms
23,292 KB |
testcase_51 | AC | 851 ms
23,832 KB |
testcase_52 | AC | 916 ms
23,316 KB |
testcase_53 | AC | 844 ms
24,288 KB |
testcase_54 | AC | 925 ms
23,376 KB |
testcase_55 | AC | 821 ms
23,400 KB |
testcase_56 | AC | 827 ms
23,928 KB |
testcase_57 | AC | 741 ms
23,460 KB |
testcase_58 | AC | 838 ms
23,448 KB |
testcase_59 | AC | 921 ms
24,156 KB |
testcase_60 | AC | 828 ms
23,652 KB |
testcase_61 | AC | 801 ms
23,316 KB |
testcase_62 | AC | 747 ms
23,748 KB |
testcase_63 | AC | 851 ms
23,328 KB |
testcase_64 | AC | 901 ms
23,400 KB |
testcase_65 | AC | 1,156 ms
23,928 KB |
testcase_66 | AC | 926 ms
23,928 KB |
testcase_67 | AC | 793 ms
24,156 KB |
testcase_68 | AC | 837 ms
23,664 KB |
testcase_69 | AC | 865 ms
23,436 KB |
testcase_70 | AC | 819 ms
23,292 KB |
testcase_71 | AC | 894 ms
24,036 KB |
testcase_72 | AC | 681 ms
23,316 KB |
testcase_73 | AC | 838 ms
23,544 KB |
testcase_74 | AC | 721 ms
24,072 KB |
testcase_75 | AC | 873 ms
23,460 KB |
testcase_76 | AC | 913 ms
24,036 KB |
testcase_77 | AC | 945 ms
24,312 KB |
testcase_78 | AC | 877 ms
23,952 KB |
testcase_79 | AC | 817 ms
23,556 KB |
testcase_80 | AC | 888 ms
24,288 KB |
testcase_81 | AC | 784 ms
23,940 KB |
testcase_82 | AC | 843 ms
24,300 KB |
testcase_83 | AC | 821 ms
23,436 KB |
testcase_84 | AC | 847 ms
23,424 KB |
testcase_85 | AC | 949 ms
24,024 KB |
testcase_86 | AC | 898 ms
23,316 KB |
testcase_87 | AC | 769 ms
24,288 KB |
testcase_88 | AC | 946 ms
23,292 KB |
testcase_89 | AC | 880 ms
24,240 KB |
testcase_90 | AC | 923 ms
23,568 KB |
testcase_91 | AC | 961 ms
23,532 KB |
testcase_92 | AC | 729 ms
23,436 KB |
testcase_93 | AC | 883 ms
24,060 KB |
testcase_94 | AC | 733 ms
24,264 KB |
testcase_95 | AC | 875 ms
24,168 KB |
testcase_96 | AC | 917 ms
23,448 KB |
testcase_97 | AC | 847 ms
23,844 KB |
testcase_98 | AC | 851 ms
23,928 KB |
testcase_99 | AC | 824 ms
23,424 KB |
ソースコード
#pragma GCC target("avx2") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #include <bits/stdc++.h> using namespace std; using lint = long long int; using P = pair<int, int>; using PL = pair<lint, lint>; #define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++) #define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--) #define REP(i, n) FOR(i,0,n) #define IREP(i, n) IFOR(i,0,n) #define ALL(a) (a).begin(),(a).end() constexpr int MOD = 1000000007; constexpr lint B1 = 1532834020; constexpr lint M1 = 2147482409; constexpr lint B2 = 1388622299; constexpr lint M2 = 2147478017; constexpr int INF = 1e9; void yes(bool expr) {cout << (expr ? "Yes" : "No") << "\n";} template<class T>void chmax(T &a, const T &b) { if (a<b) a=b; } template<class T>void chmin(T &a, const T &b) { if (b<a) a=b; } vector<int> dx = {-1, -1, 0, 0, 1, 1}; vector<int> dy = {-1, 0, -1, 1, 0, 1}; struct Enemy { int x, y = 59, h, p, init_h; }; struct State { int x, y, p; unordered_set<int> defeated_enemy; int best_move = INF; }; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); //vector<int> P(25); //REP(i, 25) cin >> P[i]; vector<int> enemy_cnt(25); int enemy_s = 0; vector<Enemy> enemy; int cur_x = 12; int cur_power = 100; int score_sum = 0; FOR(turn, 1, 1001) { cerr << turn << " " << cur_x << " " << cur_power << " " << score_sum << endl; FOR(i, enemy_s, enemy.size()) { enemy[i].y--; if(enemy[i].y == -1) enemy_s++; } int n; cin >> n; if(n == -1) return 0; REP(i, n) { Enemy e; cin >> e.h >> e.p >> e.x; e.init_h = e.h; enemy.push_back(e); } REP(i, n) enemy_cnt[enemy[i].x]++; //倒した敵の集合->状態 を管理してループを回す //k体の敵を最速で倒せる状態を求める double min_value = INF; int best_move = 0; vector<State> states; states.push_back({cur_x, 0, cur_power, {}, INF}); int ptr = 0; while(ptr < states.size()) { State st = states[ptr++]; vector<vector<bool>> is_enemy(25, vector<bool>(60)); FOR(i, enemy_s, enemy.size()) if(enemy[i].h > 0 && !st.defeated_enemy.count(i)) is_enemy[enemy[i].x][enemy[i].y] = true; //ある敵のみを倒すことを考えて移動した場合を考える //倒した敵の集合を管理 //その敵に相対することのできる位置までの最小距離をDPで求める //その敵を倒せるかどうかを判定 vector<vector<int>> dp(25, vector<int>(60, INF)); vector<vector<int>> dpd(25, vector<int>(60, INF)); dp[st.x][st.y] = 0; dpd[st.x][st.y] = 0; FOR(j, st.y, 59) REP(i, 25) if(dp[i][j] != INF) for(int d : {-1, 1, 0}) { int x = (i + d + 25) % 25; int y = j + 1; if(is_enemy[x][y] || is_enemy[x][y-1]) continue; dp[x][y] = dp[i][j] + 1; if(i == cur_x && j == 0) dpd[x][y] = d; else dpd[x][y] = dpd[i][j]; } FOR(i, enemy_s, enemy.size()) { if(enemy[i].h <= 0) continue; if(st.defeated_enemy.count(i)) continue; int x = enemy[i].x; int y = enemy[i].y; int miny = INF; while(true) { y--; if(y == -1) break; if(is_enemy[x][y]) break; if(dp[x][y] != INF) miny = y; } if(miny == INF) continue; int dist = enemy[i].y - miny; int need_turn = enemy[i].h / (st.p / 100) + (enemy[i].h % (st.p/100) != 0); if(need_turn > dist) continue; double value = miny - ((int)st.defeated_enemy.size())*10; if(value < min_value) { min_value = value; if(st.best_move == INF) best_move = dpd[x][miny]; else best_move = st.best_move; } if(st.defeated_enemy.size() == 0) { //状態の追加 State nst; nst.x = x; nst.y = miny + need_turn; nst.p = st.p + enemy[i].p; for(int j : st.defeated_enemy) nst.defeated_enemy.insert(j); nst.defeated_enemy.insert(i); nst.best_move = st.best_move; if(st.best_move == INF) nst.best_move = dpd[x][miny]; states.push_back(nst); } } } if(best_move == 0) cout << "S" << endl; else if(best_move == -1) cout << "L" << endl; else cout << "R" << endl; cout.flush(); cur_x = (cur_x + best_move + 25) % 25; //update int min_y = INF; int damage_enemy = -1; FOR(i, enemy_s, enemy.size()) { if(enemy[i].x == cur_x && enemy[i].y >= 0 && enemy[i].y < min_y && enemy[i].h > 0) { min_y = enemy[i].y; damage_enemy = i; } } if(damage_enemy != -1) { enemy[damage_enemy].h -= (cur_power/100); if(enemy[damage_enemy].h <= 0) { cur_power += enemy[damage_enemy].p; score_sum += enemy[damage_enemy].init_h; } } } cerr << score_sum << endl; }