結果

問題 No.2375 watasou and hibit's baseball
ユーザー watasou1543watasou1543
提出日時 2023-06-21 16:37:19
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 1,382 bytes
コンパイル時間 1,284 ms
コンパイル使用メモリ 10,956 KB
実行使用メモリ 55,740 KB
最終ジャッジ日時 2023-09-22 17:24:27
合計ジャッジ時間 3,653 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
12,636 KB
testcase_01 AC 16 ms
8,152 KB
testcase_02 AC 17 ms
8,172 KB
testcase_03 TLE -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import math

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
x = [0] * 15
y = [0] * 15
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