結果
問題 |
No.5017 Tool-assisted Shooting
|
ユーザー |
|
提出日時 | 2023-07-16 17:48:01 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 64 ms / 2,000 ms |
コード長 | 1,852 bytes |
コンパイル時間 | 2,374 ms |
コンパイル使用メモリ | 208,728 KB |
実行使用メモリ | 24,348 KB |
スコア | 609,422 |
平均クエリ数 | 535.06 |
最終ジャッジ日時 | 2023-07-16 17:48:14 |
合計ジャッジ時間 | 11,476 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge11 |
純コード判定しない問題か言語 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 100 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; #define rep(i,n) for(int i=0;i<(int)(n);i++) struct Field{ vector<vector<int>> vv; vector<int> h,p; int cnt; int turn; int state; ll sum_level; Field(): vv(60,vector<int>(25,-1)),cnt(0),turn(0),state(12),sum_level(0){}; bool shift(){ turn++; int n; cin>>n; if(n==-1){ return 1; } if(vv.at(turn).at(state)>=0){ return 1; } vector<int> v(25,-1); rep(i,n){ int a,b,c; cin>>a>>b>>c; v.at(c)=cnt; h.push_back(a); p.push_back(b); cnt++; } vv.emplace_back(v); return 0; } pair<int,int> get_near(int x){ for(int i=turn;i<turn+60;i++){ if(vv.at(i).at(x)>=0){ return {i-turn,vv.at(i).at(x)}; } } return {-1,-1}; } ll level(){ return (1+sum_level/100); } void move(){ { auto [dis,nm]=get_near(state); if(nm!=-1){ if(dis*level()>=h.at(nm)){ cout<<"S"<<endl; return; } } } for(int i=1;i<5;i++){ { auto [dis,nm]=get_near((state+i)%25); if(nm!=-1){ if(dis*level()>=h.at(nm)){ cout<<"R"<<endl; state++; if(state==25) state=0; return; } } } { auto [dis,nm]=get_near((state-i+25)%25); if(nm!=-1){ if(dis*level()>=h.at(nm)){ cout<<"L"<<endl; state--; if(state<0) state+=25; return; } } } } cout<<"R"<<endl; state++; if(state==25) state=0; } bool attack(){ auto [dis,nm]=get_near(state); if(nm==-1) return 0; if(dis==0) return 1; h.at(nm)-=level(); if(h.at(nm)<=0){ vv.at(dis+turn).at(state)=-1; sum_level+=p.at(nm); } return 0; } void out_field(){ for(int i=turn+59;i>=turn;i--){ rep(j,25) cout<<vv.at(i).at(j)<<" "; cout<<endl; } } }; int main(){ Field fl; rep(lp,1000){ if(fl.shift()) break; fl.move(); if(fl.attack()) break; } }