結果
| 問題 |
No.5017 Tool-assisted Shooting
|
| ユーザー |
|
| 提出日時 | 2023-07-16 17:55:23 |
| 言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 63 ms / 2,000 ms |
| コード長 | 2,271 bytes |
| コンパイル時間 | 2,231 ms |
| コンパイル使用メモリ | 209,104 KB |
| 実行使用メモリ | 24,396 KB |
| スコア | 535,549 |
| 平均クエリ数 | 510.22 |
| 最終ジャッジ日時 | 2023-07-16 17:55:37 |
| 合計ジャッジ時間 | 11,595 ms |
|
ジャッジサーバーID (参考情報) |
judge11 / judge14 |
| 純コード判定しない問題か言語 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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++)
// randxor
unsigned int randxor(){
static unsigned int x=123456789,y=362436069,z=521288629,w=88675123;
unsigned int t=(x^(x<<11)); x=y;y=z;z=w;
return( w=(w^(w>>19))^(t^(t>>8)) );
}
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(){
int sfv=-1;
{
auto [dis,nm]=get_near(state);
if(nm!=-1){
if(dis*level()>=h.at(nm)){
cout<<"S"<<endl;
return;
}
}else{
sfv=0;
}
}
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;
}
}else if(sfv==-1){
sfv=1;
}
}
{
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;
}
}else if(sfv==-1){
sfv=2;
}
}
}
if(sfv==0){
cout<<"S"<<endl;
}else if(sfv==2){
cout<<"L"<<endl;
state--;
if(state<0) state+=25;
}else{
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;
}
}