結果

問題 No.5017 Tool-assisted Shooting
ユーザー random contestantrandom contestant
提出日時 2023-07-16 18:38:04
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 105 ms / 2,000 ms
コード長 5,348 bytes
コンパイル時間 5,390 ms
コンパイル使用メモリ 285,204 KB
実行使用メモリ 24,396 KB
スコア 4,067,260
平均クエリ数 993.68
最終ジャッジ日時 2023-07-16 18:38:23
合計ジャッジ時間 18,027 ms
ジャッジサーバーID
(参考情報)
judge17 / judge12
純コード判定しない問題か言語
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 81 ms
23,844 KB
testcase_01 AC 77 ms
24,288 KB
testcase_02 AC 77 ms
24,372 KB
testcase_03 AC 78 ms
23,640 KB
testcase_04 AC 78 ms
24,048 KB
testcase_05 AC 77 ms
23,424 KB
testcase_06 AC 78 ms
24,348 KB
testcase_07 AC 78 ms
24,060 KB
testcase_08 AC 77 ms
24,000 KB
testcase_09 AC 85 ms
23,664 KB
testcase_10 AC 77 ms
24,264 KB
testcase_11 AC 77 ms
24,084 KB
testcase_12 AC 77 ms
24,072 KB
testcase_13 AC 77 ms
23,544 KB
testcase_14 AC 78 ms
23,664 KB
testcase_15 AC 76 ms
23,664 KB
testcase_16 AC 76 ms
24,372 KB
testcase_17 AC 78 ms
23,628 KB
testcase_18 AC 77 ms
23,412 KB
testcase_19 AC 76 ms
24,000 KB
testcase_20 AC 78 ms
23,640 KB
testcase_21 AC 78 ms
24,288 KB
testcase_22 AC 77 ms
23,664 KB
testcase_23 AC 77 ms
23,412 KB
testcase_24 AC 80 ms
24,288 KB
testcase_25 AC 47 ms
24,396 KB
testcase_26 AC 79 ms
23,664 KB
testcase_27 AC 77 ms
23,388 KB
testcase_28 AC 77 ms
24,324 KB
testcase_29 AC 76 ms
23,424 KB
testcase_30 AC 84 ms
24,000 KB
testcase_31 AC 78 ms
23,400 KB
testcase_32 AC 77 ms
23,628 KB
testcase_33 AC 78 ms
24,372 KB
testcase_34 AC 89 ms
23,388 KB
testcase_35 AC 85 ms
23,400 KB
testcase_36 AC 85 ms
24,372 KB
testcase_37 AC 85 ms
23,664 KB
testcase_38 AC 79 ms
23,388 KB
testcase_39 AC 79 ms
23,988 KB
testcase_40 AC 85 ms
24,000 KB
testcase_41 AC 77 ms
23,664 KB
testcase_42 AC 77 ms
23,664 KB
testcase_43 AC 77 ms
24,300 KB
testcase_44 AC 77 ms
23,376 KB
testcase_45 AC 77 ms
23,616 KB
testcase_46 AC 78 ms
23,544 KB
testcase_47 AC 77 ms
23,532 KB
testcase_48 AC 77 ms
23,376 KB
testcase_49 AC 77 ms
24,276 KB
testcase_50 AC 85 ms
24,048 KB
testcase_51 AC 77 ms
23,988 KB
testcase_52 AC 78 ms
24,264 KB
testcase_53 AC 77 ms
23,520 KB
testcase_54 AC 78 ms
23,388 KB
testcase_55 AC 78 ms
23,640 KB
testcase_56 AC 79 ms
23,820 KB
testcase_57 AC 77 ms
24,372 KB
testcase_58 AC 77 ms
23,664 KB
testcase_59 AC 78 ms
23,844 KB
testcase_60 AC 77 ms
23,424 KB
testcase_61 AC 78 ms
23,940 KB
testcase_62 AC 79 ms
23,544 KB
testcase_63 AC 78 ms
23,652 KB
testcase_64 AC 78 ms
24,012 KB
testcase_65 AC 79 ms
23,664 KB
testcase_66 AC 77 ms
23,424 KB
testcase_67 AC 77 ms
23,376 KB
testcase_68 AC 78 ms
24,276 KB
testcase_69 AC 78 ms
24,048 KB
testcase_70 AC 84 ms
24,276 KB
testcase_71 AC 84 ms
24,048 KB
testcase_72 AC 77 ms
23,664 KB
testcase_73 AC 78 ms
23,532 KB
testcase_74 AC 77 ms
23,664 KB
testcase_75 AC 78 ms
23,532 KB
testcase_76 AC 77 ms
23,412 KB
testcase_77 AC 78 ms
24,348 KB
testcase_78 AC 77 ms
24,348 KB
testcase_79 AC 77 ms
23,844 KB
testcase_80 AC 78 ms
24,276 KB
testcase_81 AC 105 ms
24,036 KB
testcase_82 AC 77 ms
23,388 KB
testcase_83 AC 78 ms
24,012 KB
testcase_84 AC 78 ms
24,060 KB
testcase_85 AC 78 ms
24,036 KB
testcase_86 AC 77 ms
24,000 KB
testcase_87 AC 76 ms
23,664 KB
testcase_88 AC 78 ms
24,276 KB
testcase_89 AC 78 ms
24,060 KB
testcase_90 AC 77 ms
23,640 KB
testcase_91 AC 84 ms
23,640 KB
testcase_92 AC 77 ms
23,532 KB
testcase_93 AC 77 ms
23,424 KB
testcase_94 AC 77 ms
23,532 KB
testcase_95 AC 80 ms
23,664 KB
testcase_96 AC 81 ms
24,324 KB
testcase_97 AC 77 ms
23,412 KB
testcase_98 AC 78 ms
23,820 KB
testcase_99 AC 77 ms
24,336 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// #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){ // 倒したら
        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){ // 倒したら
        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; // ビームサーチ
    { // 右向き移動
      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+(bool)s.size())*(power/100)){
              get_power = 10*hp[i][nowx].second *(1000-turn) + hp[i][nowx].first*turn;
              take_turn = (hp[i][nowx].first) / (power/100) + (bool)((hp[i][nowx].first) % (power/100)) - (bool)s.size();
            }
            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--;
      }
    }{ // 左向き移動
      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+(bool)s.size())*(power/100)){
              get_power = 10*hp[i][nowx].second *(1000-turn) + hp[i][nowx].first*turn;
              take_turn = (hp[i][nowx].first) / (power/100) + (bool)((hp[i][nowx].first) % (power/100)) - (bool)s.size();
            }
            break;
          }
        }
        beams.emplace_back(get_power / (s.size()+take_turn), 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();
}
0