結果
問題 | No.5017 Tool-assisted Shooting |
ユーザー |
|
提出日時 | 2023-07-16 17:10:45 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 126 ms / 2,000 ms |
コード長 | 4,559 bytes |
コンパイル時間 | 4,945 ms |
コンパイル使用メモリ | 284,836 KB |
実行使用メモリ | 24,360 KB |
スコア | 3,198,899 |
平均クエリ数 | 3207.54 |
最終ジャッジ日時 | 2023-07-16 17:11:06 |
合計ジャッジ時間 | 19,299 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge16 |
純コード判定しない問題か言語 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 100 |
ソースコード
// #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;rep(r,24){ // 移動回数// ここで攻撃を行うdouble get_power = 0;int take_turn = 100; // 敵を撃破するのにかかる時間for(int i = nowy; i >= 0; i--){if (hp[i][nowx].first){//そもそも破壊可能か?if (hp[i][nowx].first <= (nowy-i)*(power/100)){get_power = hp[i][nowx].second;take_turn = (hp[i][nowx].first) / (power/100) + (bool)((hp[i][nowx].first) % (power/100));}break;}}beams.emplace_back(get_power / (s.size()+take_turn), 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--;}}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();}