結果
問題 | No.5017 Tool-assisted Shooting |
ユーザー | Shun_PI |
提出日時 | 2023-07-16 18:06:39 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 1,180 ms / 2,000 ms |
コード長 | 5,721 bytes |
コンパイル時間 | 3,497 ms |
コンパイル使用メモリ | 211,672 KB |
実行使用メモリ | 24,384 KB |
スコア | 4,311,830 |
平均クエリ数 | 1000.00 |
最終ジャッジ日時 | 2023-07-16 18:09:03 |
合計ジャッジ時間 | 96,557 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge11 |
純コード判定しない問題か言語 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 881 ms
23,376 KB |
testcase_01 | AC | 946 ms
23,292 KB |
testcase_02 | AC | 702 ms
23,916 KB |
testcase_03 | AC | 851 ms
23,928 KB |
testcase_04 | AC | 782 ms
23,424 KB |
testcase_05 | AC | 783 ms
23,736 KB |
testcase_06 | AC | 852 ms
24,048 KB |
testcase_07 | AC | 920 ms
23,292 KB |
testcase_08 | AC | 782 ms
23,268 KB |
testcase_09 | AC | 806 ms
23,676 KB |
testcase_10 | AC | 901 ms
23,532 KB |
testcase_11 | AC | 756 ms
23,904 KB |
testcase_12 | AC | 842 ms
24,024 KB |
testcase_13 | AC | 901 ms
23,628 KB |
testcase_14 | AC | 914 ms
23,712 KB |
testcase_15 | AC | 866 ms
23,400 KB |
testcase_16 | AC | 783 ms
23,844 KB |
testcase_17 | AC | 921 ms
24,252 KB |
testcase_18 | AC | 880 ms
24,060 KB |
testcase_19 | AC | 942 ms
23,508 KB |
testcase_20 | AC | 855 ms
23,268 KB |
testcase_21 | AC | 955 ms
23,256 KB |
testcase_22 | AC | 712 ms
23,544 KB |
testcase_23 | AC | 804 ms
24,216 KB |
testcase_24 | AC | 929 ms
24,060 KB |
testcase_25 | AC | 971 ms
23,928 KB |
testcase_26 | AC | 809 ms
23,304 KB |
testcase_27 | AC | 826 ms
24,264 KB |
testcase_28 | AC | 971 ms
23,268 KB |
testcase_29 | AC | 702 ms
23,736 KB |
testcase_30 | AC | 729 ms
23,904 KB |
testcase_31 | AC | 755 ms
23,736 KB |
testcase_32 | AC | 919 ms
23,280 KB |
testcase_33 | AC | 997 ms
23,388 KB |
testcase_34 | AC | 836 ms
24,276 KB |
testcase_35 | AC | 877 ms
23,856 KB |
testcase_36 | AC | 727 ms
23,292 KB |
testcase_37 | AC | 908 ms
23,424 KB |
testcase_38 | AC | 876 ms
23,520 KB |
testcase_39 | AC | 908 ms
23,424 KB |
testcase_40 | AC | 898 ms
24,096 KB |
testcase_41 | AC | 847 ms
24,036 KB |
testcase_42 | AC | 929 ms
23,544 KB |
testcase_43 | AC | 846 ms
23,844 KB |
testcase_44 | AC | 892 ms
23,724 KB |
testcase_45 | AC | 879 ms
23,544 KB |
testcase_46 | AC | 923 ms
24,384 KB |
testcase_47 | AC | 752 ms
23,928 KB |
testcase_48 | AC | 959 ms
23,532 KB |
testcase_49 | AC | 890 ms
24,060 KB |
testcase_50 | AC | 831 ms
23,412 KB |
testcase_51 | AC | 926 ms
23,424 KB |
testcase_52 | AC | 944 ms
24,036 KB |
testcase_53 | AC | 884 ms
23,556 KB |
testcase_54 | AC | 939 ms
24,024 KB |
testcase_55 | AC | 846 ms
23,652 KB |
testcase_56 | AC | 849 ms
23,940 KB |
testcase_57 | AC | 764 ms
23,268 KB |
testcase_58 | AC | 876 ms
23,640 KB |
testcase_59 | AC | 937 ms
23,664 KB |
testcase_60 | AC | 870 ms
23,508 KB |
testcase_61 | AC | 816 ms
23,304 KB |
testcase_62 | AC | 801 ms
23,412 KB |
testcase_63 | AC | 886 ms
23,652 KB |
testcase_64 | AC | 898 ms
23,292 KB |
testcase_65 | AC | 1,180 ms
23,292 KB |
testcase_66 | AC | 952 ms
23,304 KB |
testcase_67 | AC | 848 ms
24,300 KB |
testcase_68 | AC | 842 ms
24,300 KB |
testcase_69 | AC | 857 ms
24,372 KB |
testcase_70 | AC | 850 ms
23,304 KB |
testcase_71 | AC | 887 ms
23,412 KB |
testcase_72 | AC | 689 ms
23,520 KB |
testcase_73 | AC | 896 ms
23,928 KB |
testcase_74 | AC | 707 ms
23,916 KB |
testcase_75 | AC | 901 ms
24,204 KB |
testcase_76 | AC | 921 ms
23,520 KB |
testcase_77 | AC | 958 ms
23,280 KB |
testcase_78 | AC | 858 ms
24,024 KB |
testcase_79 | AC | 832 ms
23,640 KB |
testcase_80 | AC | 934 ms
24,240 KB |
testcase_81 | AC | 799 ms
23,544 KB |
testcase_82 | AC | 854 ms
23,664 KB |
testcase_83 | AC | 827 ms
24,288 KB |
testcase_84 | AC | 891 ms
23,520 KB |
testcase_85 | AC | 942 ms
23,940 KB |
testcase_86 | AC | 892 ms
24,024 KB |
testcase_87 | AC | 834 ms
23,316 KB |
testcase_88 | AC | 937 ms
23,832 KB |
testcase_89 | AC | 907 ms
24,024 KB |
testcase_90 | AC | 973 ms
24,024 KB |
testcase_91 | AC | 986 ms
23,532 KB |
testcase_92 | AC | 713 ms
23,544 KB |
testcase_93 | AC | 932 ms
24,168 KB |
testcase_94 | AC | 725 ms
23,424 KB |
testcase_95 | AC | 911 ms
24,264 KB |
testcase_96 | AC | 944 ms
24,276 KB |
testcase_97 | AC | 901 ms
23,508 KB |
testcase_98 | AC | 874 ms
23,520 KB |
testcase_99 | AC | 896 ms
23,412 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 = -(double)(st.p + enemy[i].p - cur_power) / (miny+need_turn+1) - st.defeated_enemy.size()*10000; 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; }