結果

問題 No.5017 Tool-assisted Shooting
ユーザー cho435
提出日時 2023-07-16 18:01:44
言語 C++17(gcc12)
(gcc 12.3.0 + boost 1.87.0)
結果
AC  
実行時間 62 ms / 2,000 ms
コード長 2,310 bytes
コンパイル時間 2,354 ms
コンパイル使用メモリ 208,540 KB
実行使用メモリ 24,300 KB
スコア 547,295
平均クエリ数 511.43
最終ジャッジ日時 2023-07-16 18:01:56
合計ジャッジ時間 11,617 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
純コード判定しない問題か言語
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
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++)

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