結果

問題 No.2375 watasou and hibit's baseball
ユーザー shobonvipshobonvip
提出日時 2023-07-07 23:25:53
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 108 ms / 2,000 ms
コード長 1,372 bytes
コンパイル時間 4,464 ms
コンパイル使用メモリ 264,380 KB
実行使用メモリ 21,132 KB
最終ジャッジ日時 2023-09-29 01:09:53
合計ジャッジ時間 7,434 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 29 ms
11,604 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 108 ms
20,808 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 12 ms
7,324 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 4 ms
4,380 KB
testcase_12 AC 53 ms
21,132 KB
testcase_13 AC 23 ms
11,652 KB
testcase_14 AC 1 ms
4,376 KB
testcase_15 AC 9 ms
5,244 KB
testcase_16 AC 5 ms
4,376 KB
testcase_17 AC 50 ms
20,820 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 1 ms
4,376 KB
testcase_20 AC 4 ms
4,380 KB
testcase_21 AC 49 ms
20,816 KB
testcase_22 AC 1 ms
4,380 KB
testcase_23 AC 49 ms
20,908 KB
testcase_24 AC 49 ms
20,812 KB
testcase_25 AC 2 ms
4,376 KB
testcase_26 AC 60 ms
20,780 KB
testcase_27 AC 63 ms
20,812 KB
testcase_28 AC 66 ms
20,868 KB
testcase_29 AC 71 ms
20,812 KB
testcase_30 AC 75 ms
20,808 KB
testcase_31 AC 69 ms
20,800 KB
testcase_32 AC 74 ms
20,804 KB
testcase_33 AC 64 ms
20,844 KB
testcase_34 AC 61 ms
20,808 KB
testcase_35 AC 75 ms
20,904 KB
testcase_36 AC 69 ms
20,996 KB
testcase_37 AC 60 ms
20,804 KB
testcase_38 AC 49 ms
20,864 KB
権限があれば一括ダウンロードができます

ソースコード

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){
	if (i == n) return 0;
	if (j == n) return 1e18;
	return abs(x[i] - x[j]) + abs(y[i] - y[j]);
}

ll kdist(int i, int j){
	if (i == n) return 1e18;
	if (j == n) return 1e18;
	return abs(k[i] - k[j]);
}

int main(){
	cin >> n >> a >> b;
	rep(i,0,n){
		cin >> x[i] >> y[i] >> k[i];
	}
	vector dp(1<<n, vector(n+1, vector<bool>(n+1)));
	dp[0][n][n] = true;
	rep(i,0,1<<n){
		rep(j,0,n+1){
			rep(k,0,n+1){
				if (!dp[i][j][k]) continue;
				rep(l,0,n){
					if ((i >> l & 1) == 0){
						if (a <= dist(l, k) + dist(j, l) || b <= kdist(l, k)){
							dp[i|(1<<l)][k][l] = true;
						}
					}
				}
			}
		}
	}
	int ans = 0;
	rep(i,0,1<<n){
		int val = __builtin_popcount(i);
		rep(j,0,n+1){
			rep(k,0,n+1){
				if (dp[i][j][k]) chmax(ans, val);
			}
		}
	}
	cout << ans << endl;
}
0