結果
問題 | No.5017 Tool-assisted Shooting |
ユーザー | FplusFplusF |
提出日時 | 2023-07-16 17:27:45 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 83 ms / 2,000 ms |
コード長 | 5,164 bytes |
コンパイル時間 | 2,309 ms |
コンパイル使用メモリ | 215,588 KB |
実行使用メモリ | 24,408 KB |
スコア | 825,276 |
平均クエリ数 | 518.48 |
最終ジャッジ日時 | 2023-07-16 17:27:58 |
合計ジャッジ時間 | 11,989 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge11 |
純コード判定しない問題か言語 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 47 ms
24,264 KB |
testcase_01 | AC | 29 ms
23,676 KB |
testcase_02 | AC | 66 ms
23,388 KB |
testcase_03 | AC | 57 ms
24,336 KB |
testcase_04 | AC | 70 ms
23,652 KB |
testcase_05 | AC | 42 ms
24,360 KB |
testcase_06 | AC | 52 ms
23,568 KB |
testcase_07 | AC | 41 ms
23,424 KB |
testcase_08 | AC | 44 ms
23,400 KB |
testcase_09 | AC | 30 ms
24,276 KB |
testcase_10 | AC | 51 ms
24,072 KB |
testcase_11 | AC | 40 ms
24,276 KB |
testcase_12 | AC | 46 ms
24,084 KB |
testcase_13 | AC | 47 ms
23,244 KB |
testcase_14 | AC | 79 ms
23,544 KB |
testcase_15 | AC | 50 ms
24,048 KB |
testcase_16 | AC | 83 ms
23,436 KB |
testcase_17 | AC | 29 ms
23,436 KB |
testcase_18 | AC | 83 ms
24,396 KB |
testcase_19 | AC | 33 ms
23,652 KB |
testcase_20 | AC | 83 ms
24,396 KB |
testcase_21 | AC | 50 ms
23,424 KB |
testcase_22 | AC | 66 ms
24,372 KB |
testcase_23 | AC | 64 ms
23,544 KB |
testcase_24 | AC | 40 ms
23,568 KB |
testcase_25 | AC | 52 ms
23,424 KB |
testcase_26 | AC | 81 ms
23,676 KB |
testcase_27 | AC | 47 ms
24,324 KB |
testcase_28 | AC | 71 ms
23,856 KB |
testcase_29 | AC | 78 ms
24,408 KB |
testcase_30 | AC | 79 ms
24,336 KB |
testcase_31 | AC | 69 ms
23,376 KB |
testcase_32 | AC | 51 ms
23,664 KB |
testcase_33 | AC | 40 ms
23,400 KB |
testcase_34 | AC | 44 ms
23,832 KB |
testcase_35 | AC | 42 ms
23,676 KB |
testcase_36 | AC | 52 ms
24,120 KB |
testcase_37 | AC | 55 ms
24,048 KB |
testcase_38 | AC | 37 ms
24,024 KB |
testcase_39 | AC | 51 ms
23,676 KB |
testcase_40 | AC | 49 ms
24,360 KB |
testcase_41 | AC | 80 ms
23,544 KB |
testcase_42 | AC | 39 ms
24,048 KB |
testcase_43 | AC | 55 ms
23,664 KB |
testcase_44 | AC | 32 ms
24,300 KB |
testcase_45 | AC | 79 ms
23,544 KB |
testcase_46 | AC | 30 ms
23,412 KB |
testcase_47 | AC | 33 ms
23,400 KB |
testcase_48 | AC | 39 ms
24,336 KB |
testcase_49 | AC | 64 ms
23,412 KB |
testcase_50 | AC | 29 ms
23,676 KB |
testcase_51 | AC | 31 ms
23,568 KB |
testcase_52 | AC | 81 ms
23,376 KB |
testcase_53 | AC | 64 ms
24,036 KB |
testcase_54 | AC | 34 ms
24,072 KB |
testcase_55 | AC | 54 ms
24,060 KB |
testcase_56 | AC | 29 ms
23,568 KB |
testcase_57 | AC | 30 ms
24,336 KB |
testcase_58 | AC | 33 ms
23,544 KB |
testcase_59 | AC | 54 ms
24,036 KB |
testcase_60 | AC | 31 ms
24,396 KB |
testcase_61 | AC | 31 ms
23,544 KB |
testcase_62 | AC | 43 ms
23,592 KB |
testcase_63 | AC | 83 ms
23,652 KB |
testcase_64 | AC | 33 ms
23,388 KB |
testcase_65 | AC | 45 ms
23,652 KB |
testcase_66 | AC | 34 ms
23,856 KB |
testcase_67 | AC | 79 ms
24,024 KB |
testcase_68 | AC | 31 ms
23,400 KB |
testcase_69 | AC | 34 ms
24,060 KB |
testcase_70 | AC | 31 ms
23,556 KB |
testcase_71 | AC | 74 ms
23,724 KB |
testcase_72 | AC | 46 ms
23,856 KB |
testcase_73 | AC | 34 ms
23,856 KB |
testcase_74 | AC | 56 ms
23,868 KB |
testcase_75 | AC | 44 ms
24,384 KB |
testcase_76 | AC | 34 ms
23,856 KB |
testcase_77 | AC | 45 ms
23,556 KB |
testcase_78 | AC | 47 ms
23,628 KB |
testcase_79 | AC | 59 ms
24,288 KB |
testcase_80 | AC | 37 ms
24,288 KB |
testcase_81 | AC | 33 ms
23,544 KB |
testcase_82 | AC | 40 ms
23,412 KB |
testcase_83 | AC | 33 ms
23,844 KB |
testcase_84 | AC | 70 ms
24,048 KB |
testcase_85 | AC | 54 ms
23,556 KB |
testcase_86 | AC | 46 ms
24,288 KB |
testcase_87 | AC | 29 ms
24,036 KB |
testcase_88 | AC | 41 ms
23,676 KB |
testcase_89 | AC | 50 ms
23,844 KB |
testcase_90 | AC | 45 ms
23,664 KB |
testcase_91 | AC | 33 ms
23,652 KB |
testcase_92 | AC | 52 ms
24,360 KB |
testcase_93 | AC | 58 ms
24,384 KB |
testcase_94 | AC | 63 ms
24,024 KB |
testcase_95 | AC | 55 ms
23,436 KB |
testcase_96 | AC | 46 ms
23,448 KB |
testcase_97 | AC | 71 ms
23,652 KB |
testcase_98 | AC | 83 ms
23,400 KB |
testcase_99 | AC | 42 ms
24,036 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-1,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; dp[ii+1][jj]={ii,jj}; if(z<jj+1) continue; if(me.j<j){ if(H-1-(ii+1-1)<H&&grid[H-1-(ii+1-1)][me.j+jj].h==0&&grid[H-1-(ii+1)][me.j+jj].h==0) dp[ii+1][jj+1]={ii,jj}; }else{ if(H-1-(ii+1-1)<H&&grid[H-1-(ii+1-1)][me.j-jj].h==0&&grid[H-1-(ii+1)][me.j-jj].h==0) dp[ii+1][jj+1]={ii,jj}; } } } int t=-1; pii pa={-1,-1}; rep(ii,n+1){ if(dp[ii][z]!=pair<int,int>({-1,-1})){ t=ii; pa={ii,z}; break; } } if(t==-1||0<grid[i][j].h-(H-1-i-t)*me.l) continue; double now=(double)grid[i][j].fh/(double)(t+(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(); }