結果

問題 No.2375 watasou and hibit's baseball
ユーザー Ekiben542Ekiben542
提出日時 2023-07-08 08:48:57
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,020 bytes
コンパイル時間 305 ms
コンパイル使用メモリ 87,280 KB
実行使用メモリ 80,744 KB
最終ジャッジ日時 2023-09-29 10:05:18
合計ジャッジ時間 15,616 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
71,472 KB
testcase_01 AC 76 ms
71,444 KB
testcase_02 AC 77 ms
71,284 KB
testcase_03 AC 369 ms
79,984 KB
testcase_04 WA -
testcase_05 AC 84 ms
76,292 KB
testcase_06 AC 371 ms
79,868 KB
testcase_07 AC 75 ms
71,336 KB
testcase_08 WA -
testcase_09 AC 76 ms
71,200 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 685 ms
80,172 KB
testcase_13 WA -
testcase_14 AC 77 ms
71,456 KB
testcase_15 AC 272 ms
80,020 KB
testcase_16 AC 214 ms
79,392 KB
testcase_17 WA -
testcase_18 AC 76 ms
71,388 KB
testcase_19 AC 76 ms
71,304 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 76 ms
71,432 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 454 ms
79,876 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 563 ms
80,172 KB
testcase_34 WA -
testcase_35 AC 416 ms
79,756 KB
testcase_36 AC 401 ms
79,372 KB
testcase_37 WA -
testcase_38 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

N, A, B = map(int, input().split())
balls = [tuple(map(int, input().split())) for _ in range(N)]

def dist(i, j):
    return abs(balls[i][0] - balls[j][0]) + abs(balls[i][1] - balls[j][1])

dp = [0] * (1 << N)
for S in range(1, 1 << N):
    for i in range(N):
        if (S >> i) & 1:
            T = S ^ (1 << i)
            if T == 0:
                dp[S] = 1
            else:
                for j in range(N):
                    if (T >> j) & 1:
                        if A <= dist(i, j) or abs(balls[i][2] - balls[j][2]) >= B:
                            dp[S] = max(dp[S], dp[T] + 1)
                        else:
                            U = T ^ (1 << j)
                            if U != 0:
                                for k in range(N):
                                    if (U >> k) & 1:
                                        if A <= dist(i, j) + dist(i, k):
                                            dp[S] = max(dp[S], dp[T] + 1)

ans = dp[(1 << N) - 1]
if ans == 0:
    ans = 1
print(ans)

0