結果

問題 No.5017 Tool-assisted Shooting
ユーザー matsup10matsup10
提出日時 2023-07-16 18:47:56
言語 C++17(gcc12)
(gcc 12.3.0 + boost 1.87.0)
結果
AC  
実行時間 66 ms / 2,000 ms
コード長 3,827 bytes
コンパイル時間 6,342 ms
コンパイル使用メモリ 327,328 KB
実行使用メモリ 24,396 KB
スコア 30,378
平均クエリ数 1000.00
最終ジャッジ日時 2023-07-16 18:49:15
合計ジャッジ時間 15,220 ms
ジャッジサーバーID
(参考情報)
judge12 / judge16
純コード判定しない問題か言語
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 100
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/extc++.h>
#include <atcoder/all>

using namespace std;
using ll = long long;
#define REP(i,n) for(int i=0;i<int(n);i++)
#define FOR(i,a,b) for(int i=a;i<=int(b);i++)
#define ALL(x) x.begin(),x.end()
#define INF INT_MAX
#define INFL LLONG_MAX / 4
using namespace atcoder;
using mint = modint998244353;
template<typename T> void chmin(T& a, T b) { a = min(a, b); }
template<typename T> void chmax(T& a, T b) { a = max(a, b); }
#define PR(x) cerr << #x << "=" << x << endl
using i128 = __int128_t;

int main_proc() {
  // h, p
  vector f(1100, vector<pair<int, int>>(25));
  vector<queue<int>> opp_ys(25);
  int new_opp_y = 60;
  int pow_sum = 0;
  int pos_x = 12;
  auto get_lv = [&]() {
    return 1 + pow_sum / 100;
  };

  auto valid = [&](int pos_y, char to) -> bool {
    if(to == 'L') {
      return f[pos_y+1][(pos_x+24)%25].first == 0 && f[pos_y+2][(pos_x+24)%25].first == 0;
    } else if(to == 'R') {
      PR(f[pos_y+2][(pos_x+1)%25].first);
      return f[pos_y+1][(pos_x+1)%25].first == 0 && f[pos_y+2][(pos_x+1)%25].first == 0;
    } else {
      return f[pos_y+1][pos_x].first == 0 && f[pos_y+2][pos_x].first == 0;
    }
  };

  REP(pos_y, 1000) {
    int n;
    cin >> n;
    REP(i, n) {
      int h, p, x;
      cin >> h >> p >> x;
      f[new_opp_y][x] = {h, p};
      opp_ys[x].push(new_opp_y);
    }
    new_opp_y++;

    vector<int> min_reach_turns(25, 1000);
    min_reach_turns[pos_x] = 1;
    REP(pm, 2){ 
      int now_pos_y = pos_y;
      FOR(i, 1, 24) {
        int offset = pm ? i : 25-i;
        int new_pos_x = (pos_x + offset) % 25;
        now_pos_y++;
        // PR(now_pos_y);
        // PR(new_pos_x);
        while(f[now_pos_y][new_pos_x].first && f[now_pos_y+1][new_pos_x].first) {
          now_pos_y++;
        }
        chmin(min_reach_turns[new_pos_x], now_pos_y - pos_y);
      } 
    }
    
    int min_req_turn = 1000;
    char next_to = 'S';
    
    REP(x, 25) {
      if(opp_ys[x].empty()) continue;
      int now_opp_y = opp_ys[x].front();

      int req_turn = f[now_opp_y][x].first / get_lv() + min_reach_turns[x] - 1;
      if(req_turn + pos_y >= now_opp_y) continue;
      if(min_req_turn > req_turn) {
        
        if(pos_x == x) next_to = 'S';
        if(abs(pos_x - x) < 13) {
          if(pos_x < x) next_to = 'R';
          if(pos_x > x) next_to = 'L';
        } else {
          if(pos_x < x) next_to = 'L';
          if(pos_x > x) next_to = 'R';
        }
        min_req_turn = req_turn;
      }
    }

    if(valid(pos_y, next_to)) {
      // PR(pos_y);
      // PR(pos_x);
      if(next_to == 'L') pos_x = (pos_x + 24) % 25;
      if(next_to == 'R') pos_x = (pos_x + 1) % 25;
    } else if (valid(pos_y, 'S')) {
      // PR(pos_y);
      // PR(pos_x);
      // PR(min_req_turn);
    } else if (valid(pos_y, 'R')) {
      pos_x = (pos_x + 1) % 25;
    } else {
      pos_x = (pos_x + 24) % 25;
    }

    // if(pos_y > 200) break;


    if(opp_ys[pos_x].size()) {
      f[opp_ys[pos_x].front()][pos_x].first--;
      if(f[opp_ys[pos_x].front()][pos_x].first == 0) {
        pow_sum += f[opp_ys[pos_x].front()][pos_x].second;
        f[opp_ys[pos_x].front()][pos_x] = {0, 0};
        opp_ys[pos_x].pop();
      }
    }
    cout << next_to << endl;
    
  }


  return 0;
}

void test1(int dn) {
  string fn = "/Users/tm/Desktop/atcoder/yukicoder/yukicoder_9774/yukicoder_9774/tools/in/00";
  if(dn<10) fn += '0';
  fn += to_string(dn);
  fn += ".txt";
  ifstream in(fn);
  cin.rdbuf(in.rdbuf());
  

  string fno = "/Users/tm/Desktop/atcoder/yukicoder/yukicoder_9774/yukicoder_9774/Visualizer_for_Mac/output.txt";
  ofstream out(fno);
  std::streambuf* strbuf = cout.rdbuf(out.rdbuf());
  vector<int> p(25);
  REP(i, 25) cin >> p[i];
  main_proc();
  std::cout.rdbuf(strbuf);
  
  return;
}

int main() {
  // test1(0);
  main_proc();
  return 0;
}

0