結果

問題 No.5017 Tool-assisted Shooting
ユーザー apthapth
提出日時 2023-07-16 17:45:24
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 42 ms / 2,000 ms
コード長 3,640 bytes
コンパイル時間 1,158 ms
コンパイル使用メモリ 122,044 KB
実行使用メモリ 24,324 KB
スコア 5,450
平均クエリ数 142.51
最終ジャッジ日時 2023-07-16 17:45:33
合計ジャッジ時間 8,961 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
純コード判定しない問題か言語
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 32 ms
23,376 KB
testcase_01 AC 30 ms
23,796 KB
testcase_02 AC 30 ms
23,868 KB
testcase_03 AC 29 ms
23,364 KB
testcase_04 AC 29 ms
23,532 KB
testcase_05 AC 33 ms
23,460 KB
testcase_06 AC 31 ms
23,544 KB
testcase_07 AC 33 ms
23,376 KB
testcase_08 AC 33 ms
23,856 KB
testcase_09 AC 30 ms
23,844 KB
testcase_10 AC 34 ms
23,400 KB
testcase_11 AC 33 ms
23,844 KB
testcase_12 AC 33 ms
23,832 KB
testcase_13 AC 30 ms
23,640 KB
testcase_14 AC 30 ms
23,340 KB
testcase_15 AC 31 ms
23,868 KB
testcase_16 AC 30 ms
23,652 KB
testcase_17 AC 29 ms
24,036 KB
testcase_18 AC 29 ms
23,424 KB
testcase_19 AC 39 ms
24,156 KB
testcase_20 AC 30 ms
23,436 KB
testcase_21 AC 33 ms
24,012 KB
testcase_22 AC 38 ms
23,640 KB
testcase_23 AC 33 ms
23,988 KB
testcase_24 AC 31 ms
24,216 KB
testcase_25 AC 29 ms
23,364 KB
testcase_26 AC 33 ms
24,108 KB
testcase_27 AC 29 ms
23,436 KB
testcase_28 AC 29 ms
23,436 KB
testcase_29 AC 31 ms
24,180 KB
testcase_30 AC 31 ms
23,328 KB
testcase_31 AC 32 ms
24,060 KB
testcase_32 AC 34 ms
23,844 KB
testcase_33 AC 32 ms
23,412 KB
testcase_34 AC 29 ms
23,412 KB
testcase_35 AC 30 ms
23,856 KB
testcase_36 AC 31 ms
23,340 KB
testcase_37 AC 33 ms
23,988 KB
testcase_38 AC 30 ms
24,036 KB
testcase_39 AC 32 ms
23,676 KB
testcase_40 AC 30 ms
23,388 KB
testcase_41 AC 28 ms
23,472 KB
testcase_42 AC 28 ms
23,400 KB
testcase_43 AC 31 ms
23,424 KB
testcase_44 AC 31 ms
23,544 KB
testcase_45 AC 28 ms
23,868 KB
testcase_46 AC 31 ms
23,580 KB
testcase_47 AC 29 ms
24,324 KB
testcase_48 AC 28 ms
24,060 KB
testcase_49 AC 29 ms
24,060 KB
testcase_50 AC 29 ms
24,168 KB
testcase_51 AC 28 ms
23,424 KB
testcase_52 AC 30 ms
23,844 KB
testcase_53 AC 33 ms
23,580 KB
testcase_54 AC 30 ms
24,036 KB
testcase_55 AC 31 ms
24,060 KB
testcase_56 AC 29 ms
23,532 KB
testcase_57 AC 31 ms
23,580 KB
testcase_58 AC 30 ms
23,640 KB
testcase_59 AC 30 ms
24,180 KB
testcase_60 AC 29 ms
24,108 KB
testcase_61 AC 30 ms
23,388 KB
testcase_62 AC 29 ms
23,856 KB
testcase_63 AC 29 ms
24,036 KB
testcase_64 AC 31 ms
23,988 KB
testcase_65 AC 29 ms
23,796 KB
testcase_66 AC 30 ms
23,664 KB
testcase_67 AC 29 ms
23,424 KB
testcase_68 AC 30 ms
23,556 KB
testcase_69 AC 29 ms
23,400 KB
testcase_70 AC 29 ms
23,484 KB
testcase_71 AC 29 ms
24,252 KB
testcase_72 AC 35 ms
23,556 KB
testcase_73 AC 29 ms
23,328 KB
testcase_74 AC 31 ms
23,460 KB
testcase_75 AC 28 ms
23,832 KB
testcase_76 AC 30 ms
24,180 KB
testcase_77 AC 29 ms
23,868 KB
testcase_78 AC 29 ms
23,364 KB
testcase_79 AC 42 ms
23,880 KB
testcase_80 AC 34 ms
24,048 KB
testcase_81 AC 31 ms
23,376 KB
testcase_82 AC 28 ms
24,228 KB
testcase_83 AC 29 ms
23,568 KB
testcase_84 AC 32 ms
23,784 KB
testcase_85 AC 33 ms
23,544 KB
testcase_86 AC 33 ms
23,388 KB
testcase_87 AC 30 ms
23,964 KB
testcase_88 AC 31 ms
23,388 KB
testcase_89 AC 33 ms
23,388 KB
testcase_90 AC 31 ms
23,544 KB
testcase_91 AC 28 ms
23,376 KB
testcase_92 AC 33 ms
23,424 KB
testcase_93 AC 29 ms
23,424 KB
testcase_94 AC 34 ms
24,108 KB
testcase_95 AC 31 ms
23,412 KB
testcase_96 AC 32 ms
24,060 KB
testcase_97 AC 31 ms
23,472 KB
testcase_98 AC 31 ms
23,580 KB
testcase_99 AC 30 ms
24,288 KB
権限があれば一括ダウンロードができます

ソースコード

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;
int 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 - i;
		p_r = pos + i;

		if (p_l<0 && p_r>=w) {
			break;
		}

		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);
	string db = "";
	int cnt = -1;
	
	while (true) {
		cnt++;
		int n;
		cin >> n;
		if (n == -1) {
			return 0;
		}
		if (cnt == 1000) {
			return 0;
		}
		for (int i = 0;i < h - 1;i++) {//update
			for (int j = 0;j < w;j++) {
				if (has_enemy[h - 1][j] == true) {
					col[j]--;
				}
			}

			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
		if (DEBUG == 0) {
			cout << action << endl;
			db += "#"+to_string(cnt)+"\n" + action + "\n";
		}
		else {
			db += action + "\n";
		}
		


		//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