結果
問題 | No.5017 Tool-assisted Shooting |
ユーザー | random contestant |
提出日時 | 2023-07-16 17:58:22 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 93 ms / 2,000 ms |
コード長 | 5,997 bytes |
コンパイル時間 | 5,043 ms |
コンパイル使用メモリ | 287,036 KB |
実行使用メモリ | 24,396 KB |
スコア | 3,360,520 |
平均クエリ数 | 935.89 |
最終ジャッジ日時 | 2023-07-16 17:58:42 |
合計ジャッジ時間 | 17,554 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge15 |
純コード判定しない問題か言語 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 44 ms
24,024 KB |
testcase_01 | AC | 80 ms
24,252 KB |
testcase_02 | AC | 78 ms
23,460 KB |
testcase_03 | AC | 79 ms
23,412 KB |
testcase_04 | AC | 77 ms
23,844 KB |
testcase_05 | AC | 79 ms
24,036 KB |
testcase_06 | AC | 58 ms
23,448 KB |
testcase_07 | AC | 79 ms
24,384 KB |
testcase_08 | AC | 44 ms
24,048 KB |
testcase_09 | AC | 50 ms
23,424 KB |
testcase_10 | AC | 85 ms
24,288 KB |
testcase_11 | AC | 78 ms
23,760 KB |
testcase_12 | AC | 80 ms
23,388 KB |
testcase_13 | AC | 80 ms
24,276 KB |
testcase_14 | AC | 80 ms
23,580 KB |
testcase_15 | AC | 79 ms
24,264 KB |
testcase_16 | AC | 84 ms
23,448 KB |
testcase_17 | AC | 79 ms
24,036 KB |
testcase_18 | AC | 83 ms
23,292 KB |
testcase_19 | AC | 80 ms
24,240 KB |
testcase_20 | AC | 80 ms
23,916 KB |
testcase_21 | AC | 81 ms
24,036 KB |
testcase_22 | AC | 77 ms
23,940 KB |
testcase_23 | AC | 78 ms
23,328 KB |
testcase_24 | AC | 81 ms
23,388 KB |
testcase_25 | AC | 81 ms
23,652 KB |
testcase_26 | AC | 79 ms
23,664 KB |
testcase_27 | AC | 79 ms
23,964 KB |
testcase_28 | AC | 80 ms
23,280 KB |
testcase_29 | AC | 38 ms
23,400 KB |
testcase_30 | AC | 77 ms
24,252 KB |
testcase_31 | AC | 55 ms
23,412 KB |
testcase_32 | AC | 79 ms
23,640 KB |
testcase_33 | AC | 81 ms
24,192 KB |
testcase_34 | AC | 37 ms
24,276 KB |
testcase_35 | AC | 78 ms
24,048 KB |
testcase_36 | AC | 78 ms
24,276 KB |
testcase_37 | AC | 93 ms
23,664 KB |
testcase_38 | AC | 79 ms
23,652 KB |
testcase_39 | AC | 78 ms
23,328 KB |
testcase_40 | AC | 47 ms
23,328 KB |
testcase_41 | AC | 78 ms
23,940 KB |
testcase_42 | AC | 81 ms
24,252 KB |
testcase_43 | AC | 79 ms
24,036 KB |
testcase_44 | AC | 79 ms
23,748 KB |
testcase_45 | AC | 80 ms
23,520 KB |
testcase_46 | AC | 81 ms
23,328 KB |
testcase_47 | AC | 78 ms
23,844 KB |
testcase_48 | AC | 80 ms
23,940 KB |
testcase_49 | AC | 80 ms
24,228 KB |
testcase_50 | AC | 79 ms
23,376 KB |
testcase_51 | AC | 86 ms
24,396 KB |
testcase_52 | AC | 78 ms
24,168 KB |
testcase_53 | AC | 79 ms
23,544 KB |
testcase_54 | AC | 77 ms
23,652 KB |
testcase_55 | AC | 77 ms
23,664 KB |
testcase_56 | AC | 77 ms
24,012 KB |
testcase_57 | AC | 77 ms
23,532 KB |
testcase_58 | AC | 78 ms
23,904 KB |
testcase_59 | AC | 79 ms
23,664 KB |
testcase_60 | AC | 79 ms
24,264 KB |
testcase_61 | AC | 76 ms
23,532 KB |
testcase_62 | AC | 32 ms
23,460 KB |
testcase_63 | AC | 78 ms
24,276 KB |
testcase_64 | AC | 79 ms
23,940 KB |
testcase_65 | AC | 87 ms
23,532 KB |
testcase_66 | AC | 78 ms
23,736 KB |
testcase_67 | AC | 78 ms
23,748 KB |
testcase_68 | AC | 79 ms
23,328 KB |
testcase_69 | AC | 78 ms
23,628 KB |
testcase_70 | AC | 79 ms
23,328 KB |
testcase_71 | AC | 80 ms
24,276 KB |
testcase_72 | AC | 84 ms
23,916 KB |
testcase_73 | AC | 80 ms
23,916 KB |
testcase_74 | AC | 83 ms
23,952 KB |
testcase_75 | AC | 80 ms
24,228 KB |
testcase_76 | AC | 80 ms
23,544 KB |
testcase_77 | AC | 56 ms
23,640 KB |
testcase_78 | AC | 79 ms
23,952 KB |
testcase_79 | AC | 80 ms
23,856 KB |
testcase_80 | AC | 80 ms
24,252 KB |
testcase_81 | AC | 78 ms
23,304 KB |
testcase_82 | AC | 78 ms
24,156 KB |
testcase_83 | AC | 79 ms
23,448 KB |
testcase_84 | AC | 86 ms
23,448 KB |
testcase_85 | AC | 80 ms
24,276 KB |
testcase_86 | AC | 80 ms
23,448 KB |
testcase_87 | AC | 78 ms
24,036 KB |
testcase_88 | AC | 42 ms
23,652 KB |
testcase_89 | AC | 79 ms
24,264 KB |
testcase_90 | AC | 78 ms
23,532 KB |
testcase_91 | AC | 80 ms
23,760 KB |
testcase_92 | AC | 74 ms
23,532 KB |
testcase_93 | AC | 79 ms
24,168 KB |
testcase_94 | AC | 85 ms
23,748 KB |
testcase_95 | AC | 87 ms
23,520 KB |
testcase_96 | AC | 80 ms
23,388 KB |
testcase_97 | AC | 78 ms
23,448 KB |
testcase_98 | AC | 78 ms
23,532 KB |
testcase_99 | AC | 76 ms
24,276 KB |
ソースコード
// #define _GLIBCXX_DEBUG #include <bits/stdc++.h> using namespace std; #include <atcoder/all> using namespace atcoder; using ll = long long; #define rep(i,n) for (ll i = 0; i < (n); ++i) using vl = vector<ll>; using vvl = vector<vl>; using P = pair<ll,ll>; #define pb push_back #define int long long #define double long double #define INF (ll) 3e18 // Ctrl + Shift + B コンパイル // Ctrl + C 中断 // ./m 実行 int h = 60; int w = 25; // フィールドはトーラス状であり、左端と右端は繋がっている int now = 12; int power = 100; // 倒して得たパワーの総和 int debug = 0; vector<vector<P>> hp(60, vector<P>(25)); vector<vector<tuple<int,int,int>>> in(1000); vl p(25); void debug_input(){ rep(i,25) cin >> p[i]; rep(i,1000){ int n; cin >> n; rep(_,n){ int h, p, w; cin >> h >> p >> w; in[i].emplace_back(h,p,w); } } cout << "debug input finish" << endl; } bool input(int turn){ for(int j = 59; j >= 1; j--) hp[j] = hp[j-1]; hp[0] = vector<P>(25); if(debug){ for(auto[h, p, x] : in[turn]){ hp[0][x] = make_pair(h, p); } return false; } int n; cin >> n; if (n == -1) return true; rep(i,n){ int h, p, x; cin >> h >> p >> x; hp[0][x] = make_pair(h, p); } return false; } void attack(){ cout << "S" << endl; for(int i = 58; i >= 0; i--){ if (hp[i][now].first){ hp[i][now].first = max(0LL, hp[i][now].first-power/100); if (hp[i][now].first == 0){ // 倒したら hp[i][now].first = 0; power += hp[i][now].second; } return; } } } void moveL(){ cout << "L" << endl; now += 24; now %= 25; for(int i = 58; i >= 0; i--){ if (hp[i][now].first){ hp[i][now].first = max(0LL, hp[i][now].first-power/100); if (hp[i][now].first == 0){ // 倒したら hp[i][now].first = 0; power += hp[i][now].second; } return; } } } void moveR(){ cout << "R" << endl; now += 1; now %= 25; for(int i = 58; i >= 0; i--){ if (hp[i][now].first){ hp[i][now].first = max(0LL, hp[i][now].first-power/100); if (hp[i][now].first == 0){ // 倒したら hp[i][now].first = 0; power += hp[i][now].second; } return; } } } void avoid(){ if (!hp[58][(now+1)%25].first && !hp[59][(now+1)%25].first) {cout << "R" << endl; now += 1;} else if (!hp[58][now].first) cout << "S" << endl; else {cout << "L" << endl; now += 24;} now %= 25; cout << "# " << now << endl; } void deb(){ cout << "# "; cout << "now potision is " << now << endl; for(int i = 58; i >= 0; i--){ if (hp[i][now].first){ cout << "# "; cout << "closest enemy is " << now << " " << 59-i << endl; cout << "# "; cout << "enemy stat : " << hp[i][now].first << " " << hp[i][now].second << endl; break; } } } void solve(){ rep(turn, 1000){ // cout << turn << endl; // cout << now << endl; if (input(turn)) return; vector<pair<double, string>> beams; // ビームサーチ // if (turn == 410){ // for(auto x : hp){ // for(auto [h, p] : x) if (h) cout << "#"; else cout << "."; // cout << endl; // } // } { // 右向き移動 string s = ""; int nowx = now; int nowy = 59; double total_get_power = 0; int total_take_turn = 0; rep(r,24){ // 移動回数 for(int i = nowy; i >= 0; i--){ if (hp[i][nowx].first){ //そもそも破壊可能か? if (hp[i][nowx].first <= (nowy-i+(bool)s.size()-total_take_turn)*(power/100)){ double get_power = 10*hp[i][nowx].second * (1000-turn) + hp[i][nowx].first*turn; int take_turn = (hp[i][nowx].first) / (power/100) + (bool)((hp[i][nowx].first) % (power/100)) - (bool)s.size(); total_get_power += get_power; total_take_turn += take_turn; beams.emplace_back(total_get_power / (s.size()+total_take_turn), s); beams.back().second.push_back('S'); } else { break; } } } beams.emplace_back(0, "S"); beams.back().second.push_back('S'); while(hp[nowy][(nowx+1)%25].first || hp[nowy-1][(nowx+1)%25].first) { s.push_back('S'); nowy--; } s.push_back('R'); nowx = (nowx + 1) % 25; nowy--; } } { // 左向き移動 string s = ""; int nowx = now; int nowy = 59; double total_get_power = 0; int total_take_turn = 0; rep(r,24){ // 移動回数 for(int i = nowy; i >= 0; i--){ if (hp[i][nowx].first){ //そもそも破壊可能か? if (hp[i][nowx].first <= (nowy-i+(bool)s.size()-total_take_turn)*(power/100)){ double get_power = 10*hp[i][nowx].second * (1000-turn) + hp[i][nowx].first*turn; int take_turn = (hp[i][nowx].first) / (power/100) + (bool)((hp[i][nowx].first) % (power/100)) - (bool)s.size(); total_get_power += get_power; total_take_turn += take_turn; beams.emplace_back(total_get_power / (s.size()+total_take_turn), s); beams.back().second.push_back('S'); } else { break; } } } beams.emplace_back(0, "S"); beams.back().second.push_back('S'); while(hp[nowy][(nowx+24)%25].first || hp[nowy-1][(nowx+24)%25].first) { s.push_back('S'); nowy--; } s.push_back('L'); nowx = (nowx+24) % 25; nowy--; } } sort(beams.rbegin(), beams.rend()); // for(auto [sc, s] : beams) { // cout << sc << " " << s << endl; // } if (beams[0].second[0] == 'S') attack(); if (beams[0].second[0] == 'L') moveL(); if (beams[0].second[0] == 'R') moveR(); // deb(); } } signed main(){ if (debug) debug_input(); solve(); }