結果

問題 No.2375 watasou and hibit's baseball
ユーザー Carpenters-CatCarpenters-Cat
提出日時 2023-07-07 22:25:48
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,354 bytes
コンパイル時間 2,281 ms
コンパイル使用メモリ 202,304 KB
実行使用メモリ 6,768 KB
最終ジャッジ日時 2023-09-28 23:51:53
合計ジャッジ時間 4,461 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
6,460 KB
testcase_01 AC 4 ms
6,560 KB
testcase_02 WA -
testcase_03 AC 20 ms
6,464 KB
testcase_04 AC 4 ms
6,496 KB
testcase_05 AC 4 ms
6,408 KB
testcase_06 AC 53 ms
6,712 KB
testcase_07 AC 3 ms
6,492 KB
testcase_08 AC 8 ms
6,456 KB
testcase_09 AC 4 ms
6,768 KB
testcase_10 AC 3 ms
6,516 KB
testcase_11 AC 4 ms
6,464 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 3 ms
6,396 KB
testcase_15 AC 6 ms
6,488 KB
testcase_16 AC 4 ms
6,624 KB
testcase_17 WA -
testcase_18 AC 4 ms
6,472 KB
testcase_19 AC 3 ms
6,528 KB
testcase_20 AC 4 ms
6,448 KB
testcase_21 WA -
testcase_22 AC 4 ms
6,496 KB
testcase_23 AC 27 ms
6,408 KB
testcase_24 AC 27 ms
6,640 KB
testcase_25 AC 3 ms
6,448 KB
testcase_26 AC 45 ms
6,560 KB
testcase_27 AC 44 ms
6,524 KB
testcase_28 WA -
testcase_29 AC 41 ms
6,696 KB
testcase_30 WA -
testcase_31 AC 45 ms
6,628 KB
testcase_32 AC 49 ms
6,628 KB
testcase_33 WA -
testcase_34 AC 41 ms
6,472 KB
testcase_35 AC 42 ms
6,696 KB
testcase_36 AC 41 ms
6,472 KB
testcase_37 WA -
testcase_38 AC 37 ms
6,460 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int main () {
	int N, A, B;
	cin >> N >> A >> B;
	int X[20], Y[20], K[20];
	for (int i = 0; i < N; i ++) cin >> X[i] >> Y[i] >> K[i];
	bool dp[(1 << 14)][14][14];
	std::vector<int> P;
	for (auto& a : dp) {
		for (auto& b : a) {
			for (auto& c : b) {
				c = false;
			}
		}
	}
	auto dst = [&](int a, int b) -> int{
		return abs(X[a] - X[b]) + abs(Y[a] - Y[b]);
	};
	int ans = 1;
	for (int i = 0; i < (1 << N); i ++) {
		P.clear();
		for (int j = 0; j < N; j ++) {
			if ((i >> j) & 1) {
				P.push_back(j);
			}
		}
		if (P.size() < 2) {
		} else if (P.size() == 2) {
			int a = P[0], b = P[1];
			dp[i][a][b] = dp[i][b][a] = (dst(a, b) >= A || abs(K[a] - K[b]) >= B);
			if (dp[i][a][b]) {
				ans = max(ans, 2);
			}
		} else {
			for (int a = 0; a < P.size(); a ++) {
				for (int b = a + 1; b < P.size(); b ++) {
					for (int c = 0; c < P.size(); c ++) {
						if (a == c || b == c) continue;
						int p = P[a], q = P[b], r = P[c];
						if (dst(p, r) + dst(q, r) >= A || abs(K[r] - K[q]) >= B) {
							dp[i][r][q] = dp[i][r][q] || dp[i ^ (1 << r)][q][p];
						} else if (abs(K[r] - K[p]) >= B) {
							dp[i][r][p] = dp[i][r][p] || dp[i ^ (1 << r)][p][q];
						}
						if (dp[i][r][q] || dp[i][r][p]) {
							ans = max(ans, (int)P.size());
						}
					}
				}
			}
		}
	}
	cout << ans << endl;
}
0