結果

問題 No.5017 Tool-assisted Shooting
ユーザー cho435
提出日時 2023-07-16 17:38:29
言語 C++17(gcc12)
(gcc 12.3.0 + boost 1.87.0)
結果
AC  
実行時間 69 ms / 2,000 ms
コード長 1,773 bytes
コンパイル時間 2,217 ms
コンパイル使用メモリ 207,116 KB
実行使用メモリ 24,372 KB
スコア 760,705
平均クエリ数 555.00
最終ジャッジ日時 2023-07-16 17:38:43
合計ジャッジ時間 12,304 ms
ジャッジサーバーID
(参考情報)
judge15 / judge16
純コード判定しない問題か言語
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 100
権限があれば一括ダウンロードができます

ソースコード

diff #

#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++){
			if(state+i<25){
				auto [dis,nm]=get_near(state+i);
				if(nm!=-1){
					if(dis*level()>=h.at(nm)){
						cout<<"R"<<endl;
						state++;
						return;
					}
				}
			}
			if(state-i>=0){
				auto [dis,nm]=get_near(state-i);
				if(nm!=-1){
					if(dis*level()>=h.at(nm)){
						cout<<"L"<<endl;
						state--;
						return;
					}
				}
			}
		}
		cout<<"S"<<endl;
	}
	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;
	}
}
0