結果

問題 No.2375 watasou and hibit's baseball
ユーザー Ekiben542Ekiben542
提出日時 2023-07-08 09:13:54
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,045 bytes
コンパイル時間 295 ms
コンパイル使用メモリ 87,232 KB
実行使用メモリ 80,608 KB
最終ジャッジ日時 2023-09-29 10:30:08
合計ジャッジ時間 14,209 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 68 ms
71,308 KB
testcase_01 AC 68 ms
71,256 KB
testcase_02 AC 68 ms
71,232 KB
testcase_03 AC 344 ms
80,068 KB
testcase_04 WA -
testcase_05 AC 74 ms
76,356 KB
testcase_06 AC 356 ms
79,864 KB
testcase_07 AC 67 ms
71,260 KB
testcase_08 WA -
testcase_09 AC 68 ms
71,564 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 668 ms
80,284 KB
testcase_13 WA -
testcase_14 AC 67 ms
71,460 KB
testcase_15 AC 252 ms
79,976 KB
testcase_16 AC 195 ms
79,452 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 67 ms
71,424 KB
testcase_20 WA -
testcase_21 AC 578 ms
80,016 KB
testcase_22 AC 66 ms
71,268 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 434 ms
79,856 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 552 ms
80,464 KB
testcase_34 WA -
testcase_35 AC 402 ms
79,824 KB
testcase_36 AC 384 ms
79,460 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 = [-1] * (1 << N)
dp[0] = 0

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] = max(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 == -1:
    ans = 1

print(ans)
0