結果
問題 | No.5017 Tool-assisted Shooting |
ユーザー | shibh308 |
提出日時 | 2023-07-16 16:14:59 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 7,383 bytes |
コンパイル時間 | 3,511 ms |
コンパイル使用メモリ | 237,720 KB |
実行使用メモリ | 24,504 KB |
スコア | 0 |
平均クエリ数 | 1.00 |
最終ジャッジ日時 | 2023-07-16 16:15:10 |
合計ジャッジ時間 | 9,888 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | WA | - |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | WA | - |
testcase_32 | WA | - |
testcase_33 | WA | - |
testcase_34 | WA | - |
testcase_35 | WA | - |
testcase_36 | WA | - |
testcase_37 | WA | - |
testcase_38 | WA | - |
testcase_39 | WA | - |
testcase_40 | WA | - |
testcase_41 | WA | - |
testcase_42 | WA | - |
testcase_43 | WA | - |
testcase_44 | WA | - |
testcase_45 | WA | - |
testcase_46 | WA | - |
testcase_47 | WA | - |
testcase_48 | WA | - |
testcase_49 | WA | - |
testcase_50 | WA | - |
testcase_51 | WA | - |
testcase_52 | WA | - |
testcase_53 | WA | - |
testcase_54 | WA | - |
testcase_55 | WA | - |
testcase_56 | WA | - |
testcase_57 | WA | - |
testcase_58 | WA | - |
testcase_59 | WA | - |
testcase_60 | WA | - |
testcase_61 | WA | - |
testcase_62 | WA | - |
testcase_63 | WA | - |
testcase_64 | WA | - |
testcase_65 | WA | - |
testcase_66 | WA | - |
testcase_67 | WA | - |
testcase_68 | WA | - |
testcase_69 | WA | - |
testcase_70 | WA | - |
testcase_71 | WA | - |
testcase_72 | WA | - |
testcase_73 | WA | - |
testcase_74 | WA | - |
testcase_75 | WA | - |
testcase_76 | WA | - |
testcase_77 | WA | - |
testcase_78 | WA | - |
testcase_79 | WA | - |
testcase_80 | WA | - |
testcase_81 | WA | - |
testcase_82 | WA | - |
testcase_83 | WA | - |
testcase_84 | WA | - |
testcase_85 | WA | - |
testcase_86 | WA | - |
testcase_87 | WA | - |
testcase_88 | WA | - |
testcase_89 | WA | - |
testcase_90 | WA | - |
testcase_91 | WA | - |
testcase_92 | WA | - |
testcase_93 | WA | - |
testcase_94 | WA | - |
testcase_95 | WA | - |
testcase_96 | WA | - |
testcase_97 | WA | - |
testcase_98 | WA | - |
testcase_99 | WA | - |
ソースコード
#include <bits/stdc++.h> // #include "atcoder/all" // #define FROMFILE #pragma GCC target("avx2") #pragma GCC optimize("Ofast") // #pragma GCC optimize("unroll-loops") using namespace std; using i64 = long long; const i64 MOD = 1e9 + 7; const i64 INF = i64(1e18); template <typename T> bool chmin(T& x, T y){ if(x > y){ x = y; return true; } return false; } template <typename T> bool chmax(T& x, T y){ if(x < y){ x = y; return true; } return false; } namespace Rnd{ // doc: https://shibh308.github.io/library/library/lib/functions/xorshift.cpp.html uint64_t x = 0xdeadbeef0110dead; uint64_t rnd(){ x ^= x << 7; x ^= x >> 9; return x; } uint64_t rnd(int n){ return rnd() % n; } double rnd_double(){ return 1.0 * rnd() / numeric_limits<uint64_t>::max(); } vector<int> rnd_perm(int n){ vector<int> v(n); iota(v.begin(), v.end(), 0); for(int i = n - 1; i >= 1; --i){ int j = rnd(i + 1); swap(v[i], v[j]); } return v; } template<typename T> void shuffle(vector<T>& v){ int n = v.size(); for(int i = n - 1; i >= 1; --i){ int j = rnd(i + 1); swap(v[i], v[j]); } } } namespace params{ void load_params(){ ifstream ifs("../params.txt"); assert(ifs.is_open()); // TODO: load params } } void read_file(istream& ifs){ // TODO: read from file } constexpr int turn_max = 1000; constexpr int n_col = 25; constexpr int height = 60; int turn = 0; int now_x = 12; struct State{ bool exists = false; int max_hp = -1; int now_hp = -1; int power = -1; }; vector<vector<State>> state; vector<vector<int>> hp_inp, power_inp, col_inp; vector<int> col_cnt; int power = 0; int score = 0; bool input(){ int n; cin >> n; if(n == -1){ return false; } hp_inp.emplace_back(n); power_inp.emplace_back(n); col_inp.emplace_back(n); for(int i = 0; i < n; ++i){ cin >> hp_inp.back()[i] >> power_inp.back()[i] >> col_inp.back()[i]; // spawn at (*, 59) state[turn + height][col_inp.back()[i]] = { true, hp_inp.back()[i], hp_inp.back()[i], power_inp.back()[i] }; ++col_cnt[col_inp.back()[i]]; } return true; } State& get_state(int col_, int height_){ return state[turn + height_ + 1][col_]; }; int solve(){ // col: [0, 25) // height: [0, 60) vector<vector<int>> target_idxes(n_col); for(int i = 0; i < height; ++i){ for(int j = 0; j < n_col; ++j){ auto& st = get_state(j, i); if(st.exists){ target_idxes[j].emplace_back(i); } } } struct BeamState{ vector<pair<int,int>> killed; int x; int target_y = 0; int target_enemy_hp = 0; int got_score = 0, got_power = 0; int mov = 0; double score() const{ return got_power - 0.00001 * target_enemy_hp; // got_score; } int level() const{ return 1 + got_power / 100; } bool operator==(const BeamState& a) const{ return killed == a.killed && target_enemy_hp == a.target_enemy_hp && x == a.x && got_power == a.got_power && got_score == a.got_score; } bool operator<(const BeamState& a) const{ return score() < a.score(); } bool operator<=(const BeamState& a) const{ return score() <= a.score(); } bool operator>(const BeamState& a) const{ return score() > a.score(); } bool operator>=(const BeamState& a) const{ return score() >= a.score(); } }; auto target = [&](BeamState& bs, int depth){ // TODO: speed up from O(n^2) for(auto y : target_idxes[bs.x]){ if(depth <= y && find(bs.killed.begin(), bs.killed.end(), make_pair(bs.x, y)) == bs.killed.end()){ // if(depth <= y){ return y; } } return -1; }; constexpr int WIDTH = 30; vector<BeamState> b_states; b_states.emplace_back(); b_states.back().x = now_x; b_states.back().got_score = score; b_states.back().got_power = power; int first_tar = target(b_states.back(), 0); assert(first_tar != 0); b_states.back().target_y = first_tar; b_states.back().target_enemy_hp = get_state(now_x, first_tar).now_hp; for(int dep = 0; dep < height && dep + turn <= turn_max; ++dep){ vector<BeamState> b_nex; for(auto& b_state : b_states){ for(auto d : {0, 1, 24}){ auto nex = b_state; nex.x = (nex.x + d) % n_col; int tar = target(nex, dep); if(dep == 0){ nex.mov = d == 24 ? -1 : d; } if(dep == tar){ continue; } if(tar != -1){ if(nex.target_y == tar){ nex.target_enemy_hp -= nex.level(); } else{ nex.target_enemy_hp = get_state(nex.x, tar).now_hp - nex.level(); } if(nex.target_enemy_hp <= 0){ nex.got_power += get_state(nex.x, tar).power; nex.got_score += get_state(nex.x, tar).max_hp; nex.killed.emplace_back(nex.x, tar); } else if(dep + 1 == tar){ continue; } } nex.target_y = tar; b_nex.emplace_back(nex); } } sort(b_nex.begin(), b_nex.end(), greater<BeamState>()); b_nex.erase(unique(b_nex.begin(), b_nex.end()), b_nex.end()); if(WIDTH < b_nex.size()){ b_nex.resize(WIDTH); } swap(b_nex, b_states); } // cout << "check: " << b_states.front().got_score << " " << b_states.front().got_power << endl; return 0; return b_states.front().mov; } void act(int x_diff){ if(x_diff == -1){ cout << 'L' << endl; now_x = (now_x + 24) % n_col; } if(x_diff == 0){ cout << 'M' << endl; now_x = (now_x + 0) % n_col; } if(x_diff == 1){ cout << 'R' << endl; now_x = (now_x + 1) % n_col; } for(int i = 0; i < height; ++i){ auto& st = get_state(now_x, i); if(st.exists){ assert(i != 0); int level = 1 + power / 100; st.now_hp -= level; if(st.now_hp <= 0){ st.exists = false; power += st.power; score += st.max_hp; } break; } } } signed main(){ clock_t st = clock(); #ifdef OPTIMIZE params::load_params(); #endif #ifdef NOSUBMIT vector<int> p(25); for(auto& x : p){ cin >> x; } #endif col_cnt.resize(n_col, 0); state.resize(turn_max + 100, vector<State>(n_col)); for(turn = 0; turn < turn_max; ++turn){ if(!input()){ break; } act(solve()); } cerr << power << endl; cerr << score << endl; /* #ifndef FROMFILE // TODO: input read_file(cin); #else ifstream ifs("../tools/in/0003.txt"); assert(ifs.is_open()); read_file(ifs); #endif */ }