結果

問題 No.2375 watasou and hibit's baseball
ユーザー watasou1543watasou1543
提出日時 2023-06-21 16:42:28
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,380 bytes
コンパイル時間 1,843 ms
コンパイル使用メモリ 87,088 KB
実行使用メモリ 179,492 KB
最終ジャッジ日時 2023-09-22 17:26:23
合計ジャッジ時間 42,357 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,212 KB
testcase_01 AC 71 ms
70,860 KB
testcase_02 AC 74 ms
71,076 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 134 ms
78,264 KB
testcase_06 TLE -
testcase_07 AC 71 ms
71,076 KB
testcase_08 WA -
testcase_09 AC 71 ms
70,856 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 73 ms
71,076 KB
testcase_15 WA -
testcase_16 AC 494 ms
86,896 KB
testcase_17 WA -
testcase_18 AC 91 ms
76,552 KB
testcase_19 AC 72 ms
71,152 KB
testcase_20 WA -
testcase_21 AC 1,648 ms
176,708 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 71 ms
71,268 KB
testcase_26 TLE -
testcase_27 WA -
testcase_28 TLE -
testcase_29 AC 1,895 ms
177,644 KB
testcase_30 TLE -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 TLE -
testcase_35 TLE -
testcase_36 TLE -
testcase_37 WA -
testcase_38 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import math
x = [0] * 15
y = [0] * 15
def d(a, b):
    return abs(x[a] - x[b]) + abs(y[a] - y[b])
n, a, b = map(int, input().split())
c = n + 1
k = [0] * 15

for i in range(1, n + 1):
    x[i], y[i], k[i] = map(int, input().split())

dp = [[[0] * (n + 1) for _ in range(n + 1)] for _ in range(1 << c)]

for i in range(1, n + 1):
    dp[(1 << i) + 1][0][i] = 1

for i in range(1 << c):
    for j in range(n + 1):
        for l in range(1, n + 1):
            if j == l:
                continue
            if ((1 << j) & i) == 0 or ((1 << l) & i) == 0:
                continue
            for m in range(n + 1):
                if m != 0 and j == 0:
                    continue
                if m == 0:
                    if d(l, j) >= a or abs(k[l] - k[j]) >= b:
                        if m == l or j == m:
                            continue
                        dp[i ^ (1 << l)][m][j] = max(dp[i ^ (1 << l)][m][j], dp[i ^ (1 << l)][m][j] + 1)
                else:
                    if d(l, j) + d(l, m) >= a or abs(k[l] - k[j]) >= b:
                        if m == l or j == m:
                            continue
                        dp[i ^ (1 << l)][m][j] = max(dp[i ^ (1 << l)][m][j], dp[i ^ (1 << l)][m][j] + 1)

ans = 0
for i in range(1 << c):
    for j in range(n + 1):
        for l in range(n + 1):
            ans = max(ans, dp[i][j][l])

print(ans)
0