結果

問題 No.5017 Tool-assisted Shooting
ユーザー apthapth
提出日時 2023-07-16 17:01:47
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 3,305 bytes
コンパイル時間 1,295 ms
コンパイル使用メモリ 118,752 KB
実行使用メモリ 34,652 KB
スコア 2,469
平均クエリ数 28.63
最終ジャッジ日時 2023-07-16 17:01:53
合計ジャッジ時間 5,753 ms
ジャッジサーバーID
(参考情報)
judge12 / judge16
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 49 ms
23,460 KB
testcase_01 AC 34 ms
23,856 KB
testcase_02 AC 40 ms
24,300 KB
testcase_03 AC 44 ms
23,700 KB
testcase_04 AC 36 ms
24,036 KB
testcase_05 AC 32 ms
23,460 KB
testcase_06 AC 45 ms
24,420 KB
testcase_07 AC 34 ms
23,424 KB
testcase_08 AC 36 ms
23,664 KB
testcase_09 AC 39 ms
24,288 KB
testcase_10 TLE -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
testcase_49 -- -
testcase_50 -- -
testcase_51 -- -
testcase_52 -- -
testcase_53 -- -
testcase_54 -- -
testcase_55 -- -
testcase_56 -- -
testcase_57 -- -
testcase_58 -- -
testcase_59 -- -
testcase_60 -- -
testcase_61 -- -
testcase_62 -- -
testcase_63 -- -
testcase_64 -- -
testcase_65 -- -
testcase_66 -- -
testcase_67 -- -
testcase_68 -- -
testcase_69 -- -
testcase_70 -- -
testcase_71 -- -
testcase_72 -- -
testcase_73 -- -
testcase_74 -- -
testcase_75 -- -
testcase_76 -- -
testcase_77 -- -
testcase_78 -- -
testcase_79 -- -
testcase_80 -- -
testcase_81 -- -
testcase_82 -- -
testcase_83 -- -
testcase_84 -- -
testcase_85 -- -
testcase_86 -- -
testcase_87 -- -
testcase_88 -- -
testcase_89 -- -
testcase_90 -- -
testcase_91 -- -
testcase_92 -- -
testcase_93 -- -
testcase_94 -- -
testcase_95 -- -
testcase_96 -- -
testcase_97 -- -
testcase_98 -- -
testcase_99 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream> 
#include <string> 
#include <vector> 
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include <cmath>
#include <iomanip>
#include <type_traits>
#include <random>
#include <numeric>
#include <climits>
const long double pi = acos(-1);
using namespace std;
#define DEBUG 0
#define ll long long
#define ull unsigned long long 

#define ld long double


int h = 60;
int w = 25;
int mid = 12;

int can_decide(bool l, bool s, bool r) {
	int n_true = 0;
	if (l == true) {
		n_true++;
	}
	if (s == true) {
		n_true++;
	}
	if (r == true) {
		n_true++;
	}
	return n_true;
}

char next_col(int pos, vector<int> &col) {
	if (col[pos] > 0) {
		return 'S';
	}
	int n_l, n_r;
	int p_l, p_r;

	for (int i = 1;i < 24;i++) {
		n_l = 0, n_r = 0;
		p_l = pos - 1;
		p_r = pos + i;
		if (p_l >= 0) {
			n_l = col[p_l];
		}
		if (p_r < w) {
			n_r = col[p_r];
		}
		if (n_l != 0 || n_r != 0) {
			if (n_r < n_l) {
				return'L';
			}
			else if (n_r > n_l) {
				return 'R';
			}
			else {
				return abs(mid - (p_l)) < abs(mid - (p_r)) ? 'L' : 'R';
			}
		}
	}
	return pos == 12 ? 'S' : (pos > 12 ? 'L' : 'R');
}



int main() {
	
	int mypos = 12;
	char action = 'S';
	int powsum = 0;
	int level = 1;
	int point = 0;
	bool can_s = true, can_l = true, can_r = true;
	vector<vector<pair<int, int>>> enemy_board(h,vector<pair<int,int>>(w));//{hp,power}
	vector<vector<bool>> has_enemy(h, vector<bool>(w,0));
	vector<int> col(w,0);
	
	while (true) {
		int n;
		cin >> n;
		if (n == -1) {
			return 0;
		}
		for (int i = 0;i < h - 1;i++) {//update
			for (int j = 0;j < w;j++) {
				enemy_board[i + 1][j] = enemy_board[i][j];
				has_enemy[i + 1][j] = has_enemy[i][j];
			}
		}

		for (int i = 0;i < n;i++) {//input
			int hp, power, x;
			cin >> hp >> power >> x;
			enemy_board[0][x].first = hp;
			enemy_board[0][x].second = power;
			has_enemy[0][x] = true;
			col[x]++;
		}


		//decision,check
		can_s = true, can_l = true, can_r = true;

		if (mypos != 0) {
			if (has_enemy[h - 1][mypos - 1] == true) {
				can_l = false;
			}

		}
		else if (mypos != w - 1) {
			if (has_enemy[h - 1][mypos + 1] == true) {
				can_r = false;
			}
		}

		if (can_decide(can_l, can_s, can_r) ==0){
			action = 'S';
		}
		else if (can_decide(can_l, can_s, can_r) == 1) {
			if (can_l == true) {
				action = 'L';
			}
			else if (can_s == true) {
				action = 'S';
			}
			else {
				action = 'R';
			}
		}
		else {
			action = next_col(mypos, col);
		}





		//output
		cout << action << endl;


		//action
		if (action == 'S') {

		}
		else if (action == 'R') {
			mypos++;
		}
		else {
			mypos--;
		}

		for (int i = h - 1;i > 0;i--) {//look ahead
			if (has_enemy[i][mypos] == true) {//敵がいたら
				enemy_board[i][mypos].first -= level;//hp減らす
				if (enemy_board[i][mypos].first <= 0) {//敵を倒したら
					has_enemy[i][mypos] = false;//敵が消滅
					powsum += enemy_board[i][mypos].second;//パワー更新
					level = 1 + (int)floorl(powsum / 100);//レベル更新
					point += enemy_board[i][mypos].first;//得点更新
					col[mypos]--;

				}
			}
		}
	}
}
0