結果
問題 | No.5017 Tool-assisted Shooting |
ユーザー | FplusFplusF |
提出日時 | 2023-07-16 17:52:01 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 111 ms / 2,000 ms |
コード長 | 5,492 bytes |
コンパイル時間 | 2,865 ms |
コンパイル使用メモリ | 214,788 KB |
実行使用メモリ | 24,336 KB |
スコア | 3,534,067 |
平均クエリ数 | 1000.00 |
最終ジャッジ日時 | 2023-07-16 17:52:18 |
合計ジャッジ時間 | 16,340 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge15 |
純コード判定しない問題か言語 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 91 ms
23,424 KB |
testcase_01 | AC | 88 ms
23,388 KB |
testcase_02 | AC | 83 ms
23,388 KB |
testcase_03 | AC | 82 ms
23,580 KB |
testcase_04 | AC | 89 ms
24,168 KB |
testcase_05 | AC | 86 ms
23,400 KB |
testcase_06 | AC | 90 ms
23,568 KB |
testcase_07 | AC | 90 ms
24,180 KB |
testcase_08 | AC | 87 ms
23,556 KB |
testcase_09 | AC | 85 ms
23,580 KB |
testcase_10 | AC | 84 ms
24,072 KB |
testcase_11 | AC | 80 ms
24,156 KB |
testcase_12 | AC | 86 ms
24,036 KB |
testcase_13 | AC | 93 ms
23,376 KB |
testcase_14 | AC | 88 ms
23,580 KB |
testcase_15 | AC | 85 ms
24,156 KB |
testcase_16 | AC | 86 ms
23,580 KB |
testcase_17 | AC | 86 ms
23,532 KB |
testcase_18 | AC | 92 ms
24,168 KB |
testcase_19 | AC | 86 ms
23,472 KB |
testcase_20 | AC | 87 ms
23,328 KB |
testcase_21 | AC | 85 ms
23,808 KB |
testcase_22 | AC | 86 ms
23,580 KB |
testcase_23 | AC | 83 ms
23,460 KB |
testcase_24 | AC | 86 ms
24,168 KB |
testcase_25 | AC | 87 ms
24,012 KB |
testcase_26 | AC | 85 ms
24,012 KB |
testcase_27 | AC | 82 ms
23,556 KB |
testcase_28 | AC | 90 ms
24,180 KB |
testcase_29 | AC | 88 ms
23,388 KB |
testcase_30 | AC | 84 ms
24,228 KB |
testcase_31 | AC | 86 ms
23,472 KB |
testcase_32 | AC | 88 ms
24,168 KB |
testcase_33 | AC | 86 ms
24,180 KB |
testcase_34 | AC | 86 ms
23,868 KB |
testcase_35 | AC | 83 ms
23,400 KB |
testcase_36 | AC | 89 ms
23,844 KB |
testcase_37 | AC | 89 ms
23,580 KB |
testcase_38 | AC | 88 ms
23,784 KB |
testcase_39 | AC | 88 ms
24,228 KB |
testcase_40 | AC | 83 ms
24,192 KB |
testcase_41 | AC | 83 ms
23,388 KB |
testcase_42 | AC | 90 ms
24,096 KB |
testcase_43 | AC | 90 ms
24,180 KB |
testcase_44 | AC | 88 ms
23,544 KB |
testcase_45 | AC | 84 ms
23,436 KB |
testcase_46 | AC | 84 ms
24,048 KB |
testcase_47 | AC | 81 ms
23,676 KB |
testcase_48 | AC | 89 ms
23,652 KB |
testcase_49 | AC | 86 ms
23,652 KB |
testcase_50 | AC | 86 ms
23,676 KB |
testcase_51 | AC | 90 ms
24,192 KB |
testcase_52 | AC | 88 ms
23,856 KB |
testcase_53 | AC | 88 ms
23,796 KB |
testcase_54 | AC | 102 ms
23,340 KB |
testcase_55 | AC | 86 ms
23,868 KB |
testcase_56 | AC | 84 ms
24,240 KB |
testcase_57 | AC | 81 ms
23,544 KB |
testcase_58 | AC | 84 ms
23,544 KB |
testcase_59 | AC | 85 ms
23,376 KB |
testcase_60 | AC | 86 ms
24,036 KB |
testcase_61 | AC | 84 ms
23,700 KB |
testcase_62 | AC | 85 ms
24,252 KB |
testcase_63 | AC | 86 ms
23,844 KB |
testcase_64 | AC | 111 ms
23,676 KB |
testcase_65 | AC | 88 ms
23,388 KB |
testcase_66 | AC | 87 ms
23,868 KB |
testcase_67 | AC | 82 ms
23,688 KB |
testcase_68 | AC | 85 ms
23,868 KB |
testcase_69 | AC | 85 ms
23,988 KB |
testcase_70 | AC | 82 ms
23,388 KB |
testcase_71 | AC | 85 ms
23,340 KB |
testcase_72 | AC | 82 ms
23,400 KB |
testcase_73 | AC | 85 ms
23,436 KB |
testcase_74 | AC | 87 ms
23,436 KB |
testcase_75 | AC | 85 ms
23,376 KB |
testcase_76 | AC | 86 ms
23,544 KB |
testcase_77 | AC | 86 ms
23,796 KB |
testcase_78 | AC | 88 ms
23,652 KB |
testcase_79 | AC | 87 ms
24,180 KB |
testcase_80 | AC | 85 ms
24,336 KB |
testcase_81 | AC | 85 ms
24,000 KB |
testcase_82 | AC | 86 ms
24,240 KB |
testcase_83 | AC | 86 ms
24,036 KB |
testcase_84 | AC | 89 ms
24,000 KB |
testcase_85 | AC | 88 ms
23,580 KB |
testcase_86 | AC | 86 ms
24,180 KB |
testcase_87 | AC | 87 ms
24,180 KB |
testcase_88 | AC | 86 ms
24,000 KB |
testcase_89 | AC | 87 ms
24,156 KB |
testcase_90 | AC | 84 ms
24,168 KB |
testcase_91 | AC | 90 ms
23,580 KB |
testcase_92 | AC | 82 ms
23,544 KB |
testcase_93 | AC | 85 ms
24,168 KB |
testcase_94 | AC | 88 ms
23,532 KB |
testcase_95 | AC | 87 ms
24,240 KB |
testcase_96 | AC | 87 ms
24,336 KB |
testcase_97 | AC | 86 ms
24,036 KB |
testcase_98 | AC | 84 ms
23,676 KB |
testcase_99 | AC | 88 ms
24,000 KB |
ソースコード
#include <bits/stdc++.h> using namespace std; const int INF=1e9; using pii=pair<int,int>; using tii=tuple<int,int,int>; #define rep(i,n) for (int i=0;i<(int)(n);i++) #define all(v) v.begin(),v.end() template<class T> void chmin(T &a,T b){ if(a>b){ a=b; } } template<class T> void chmax(T &a,T b){ if(a<b){ a=b; } } int H=60,W=25; struct Input{ int n; vector<int> h,p,x; void input_cin(){ cin >> n; if(n==-1) exit(0); h.assign(n,0); p.assign(n,0); x.assign(n,0); rep(i,n) cin >> h[i] >> p[i] >> x[i]; } }Input; struct solver{ struct shooter{ int j; int l; int s; }; struct enemy{ int fh; int h; int p; }; void solve(){ int score=0; shooter me={12,1,0}; vector<vector<enemy>> grid(H,vector<enemy>(W,{0,0,0})); int to=-1; string root; rep(t,1000){ for(int i=H-2;0<=i;i--){ rep(j,W){ grid[i+1][j]=grid[i][j]; grid[i][j]={0,0,0}; } } Input.input_cin(); rep(i,Input.n){ grid[0][Input.x[i]].fh=Input.h[i]; grid[0][Input.x[i]].h=Input.h[i]; grid[0][Input.x[i]].p=Input.p[i]; } if(to==-1){ double mx=0; int p=-1; string mx_root; rep(i,H){ rep(j,W){ if(0<grid[i][j].h){ bool ok=true; for(int k=i+1;k<H;k++){ if(0<grid[k][j].h) ok=false; } if(!ok) continue; int n=H-i,z=abs(j-me.j); vector<vector<pii>> dp(n+1,vector<pii>(z+1,{-1,-1})); dp[0][0]={-2,-2}; rep(ii,n){ rep(jj,z+1){ if(dp[ii][jj]==pair<int,int>({-1,-1})) continue; if(me.j<j){ if(0<=H-1-ii&&H-1-ii<H&&0<=H-1-(ii+1)&&H-1-(ii+1)<H&&grid[H-1-ii][me.j+jj].h==0&&grid[H-1-(ii+1)][me.j+jj].h==0) dp[ii+1][jj]={ii,jj}; if(jj+1<=z&&0<=H-1-ii&&H-1-ii<H&&0<=H-1-(ii+1)&&H-1-(ii+1)<H&&grid[H-1-ii][me.j+(jj+1)].h==0&&grid[H-1-(ii+1)][me.j+(jj+1)].h==0) dp[ii+1][jj+1]={ii,jj}; }else{ if(0<=H-1-ii&&H-1-ii<H&&0<=H-1-(ii+1)&&H-1-(ii+1)<H&&grid[H-1-ii][me.j-jj].h==0&&grid[H-1-(ii+1)][me.j-jj].h==0) dp[ii+1][jj]={ii,jj}; if(jj+1<=z&&0<=H-1-ii&&H-1-ii<H&&0<=H-1-(ii+1)&&H-1-(ii+1)<H&&grid[H-1-ii][me.j-(jj+1)].h==0&&grid[H-1-(ii+1)][me.j-(jj+1)].h==0) dp[ii+1][jj+1]={ii,jj}; } } } int tx=-1; pii pa={-1,-1}; rep(ii,n+1){ if(dp[ii][z]!=pair<int,int>({-1,-1})){ tx=ii; pa={ii,z}; break; } } if(tx==-1||0<grid[i][j].h-(H-1-i-tx)*me.l) continue; double now=(double)grid[i][j].fh/(double)(tx+(grid[i][j].h+me.l-1)/me.l); if(mx<now){ mx=now; p=j; mx_root=""; while(pa!=pair<int,int>({0,0})){ pii new_pa=dp[pa.first][pa.second]; if(new_pa.second!=pa.second){ if(me.j<j) mx_root.push_back('R'); else mx_root.push_back('L'); }else{ mx_root.push_back('S'); } pa=new_pa; } } } } } to=p; root=mx_root; } if(to==-1){ cout << "S" << endl; }else if(!root.empty()){ cout << root.back() << endl; if(root.back()=='L') me.j--; if(root.back()=='R') me.j++; root.pop_back(); }else{ cout << "S" << endl; } for(int i=H-2;0<=i;i--){ if(0<grid[i][me.j].h){ grid[i][me.j].h-=me.l; if(grid[i][me.j].h<=0){ score+=grid[i][me.j].fh; grid[i][me.j].fh=0; grid[i][me.j].h=0; me.s+=grid[i][me.j].p; grid[i][me.j].p=0; if(me.j==to) to=-1; } break; } } me.l=1+me.s/100; } } }Solver; int main(){ Solver.solve(); }