結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
6,448 KB
testcase_01 AC 4 ms
6,648 KB
testcase_02 AC 3 ms
6,452 KB
testcase_03 WA -
testcase_04 AC 4 ms
6,480 KB
testcase_05 AC 4 ms
6,480 KB
testcase_06 AC 49 ms
6,672 KB
testcase_07 AC 3 ms
6,468 KB
testcase_08 AC 8 ms
6,468 KB
testcase_09 AC 3 ms
6,404 KB
testcase_10 AC 4 ms
6,416 KB
testcase_11 AC 3 ms
6,468 KB
testcase_12 AC 38 ms
6,472 KB
testcase_13 AC 15 ms
6,504 KB
testcase_14 WA -
testcase_15 AC 7 ms
6,568 KB
testcase_16 AC 4 ms
6,508 KB
testcase_17 WA -
testcase_18 AC 4 ms
6,500 KB
testcase_19 AC 3 ms
6,424 KB
testcase_20 AC 4 ms
6,408 KB
testcase_21 AC 23 ms
6,408 KB
testcase_22 AC 4 ms
6,672 KB
testcase_23 AC 22 ms
6,468 KB
testcase_24 WA -
testcase_25 AC 3 ms
6,448 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 44 ms
6,504 KB
testcase_31 AC 40 ms
6,464 KB
testcase_32 AC 42 ms
6,720 KB
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 AC 22 ms
6,444 KB
testcase_38 WA -
権限があれば一括ダウンロードができます

ソースコード

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];
							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