結果

問題 No.2375 watasou and hibit's baseball
ユーザー shobonvipshobonvip
提出日時 2023-07-07 23:18:43
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,285 bytes
コンパイル時間 5,718 ms
コンパイル使用メモリ 258,328 KB
実行使用メモリ 8,756 KB
最終ジャッジ日時 2023-09-29 01:02:59
合計ジャッジ時間 8,118 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
8,756 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 71 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 TLE -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
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 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#include<atcoder/all>
using namespace std;
using namespace atcoder;

typedef modint998244353 mint;
typedef long long ll;

#define rep(i, s, n) for (int i = (int)(s); i < (int)(n); i++)
#define rrep(i, s, n) for (int i = (int)(n)-1; i >= (int)(s); i--)

template <typename T> bool chmin(T &a, const T &b) {
	if (a <= b) return false;
	a = b;
	return true;
}
template <typename T> bool chmax(T &a, const T &b) {
	if (a >= b) return false;
	a = b;
	return true;
}

bool hav[15];
ll x[15], y[15], k[15];
ll a, b;
int n;
vector<int> tr;
int tar = 0;

ll dist(int i, int j){
	return abs(x[i] - x[j]) + abs(y[i] - y[j]);
}

int mx(int i){
	if (tar == n) return 0;
	if ((int)tr.size() == 1){
		if (a > dist(i, tr[(int)tr.size() - 1]) && b > abs(k[i] - k[tr[(int)tr.size() - 1]])) return 0;
	}else if ((int)tr.size() >= 2){
		if (a > dist(i, tr[(int)tr.size() - 1]) + dist(i, tr[(int)tr.size() - 2]) && b > abs(k[i] - k[tr[(int)tr.size() - 1]])) return 0;
	}

	hav[i] = true;
	tr.push_back(i);

	int ret = 1;
	rep(j,0,n){
		if (!hav[j]){
			chmax(ret, mx(j) + 1);
		}
	}

	hav[i] = false;
	tr.pop_back();
	return ret;
}

int main(){
	cin >> n >> a >> b;
	rep(i,0,n){
		cin >> x[i] >> y[i] >> k[i];
	}
	int ans = 0;
	rep(i,0,n) chmax(ans, mx(i));
	cout << ans << "\n";
}
0