結果

問題 No.5017 Tool-assisted Shooting
ユーザー random contestant
提出日時 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
権限があれば一括ダウンロードができます

ソースコード

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){ //
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();
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0