結果

問題 No.2375 watasou and hibit's baseball
ユーザー flygonflygon
提出日時 2023-07-07 22:43:59
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,068 ms / 2,000 ms
コード長 2,104 bytes
コンパイル時間 2,507 ms
コンパイル使用メモリ 86,944 KB
実行使用メモリ 131,220 KB
最終ジャッジ日時 2023-09-29 00:19:21
合計ジャッジ時間 26,204 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 93 ms
71,868 KB
testcase_01 AC 92 ms
71,668 KB
testcase_02 AC 95 ms
72,308 KB
testcase_03 AC 652 ms
104,100 KB
testcase_04 AC 161 ms
78,924 KB
testcase_05 AC 121 ms
77,580 KB
testcase_06 AC 1,053 ms
129,852 KB
testcase_07 AC 92 ms
71,544 KB
testcase_08 AC 380 ms
90,280 KB
testcase_09 AC 92 ms
71,912 KB
testcase_10 AC 106 ms
77,148 KB
testcase_11 AC 257 ms
82,448 KB
testcase_12 AC 1,068 ms
130,788 KB
testcase_13 AC 619 ms
103,136 KB
testcase_14 AC 92 ms
71,716 KB
testcase_15 AC 422 ms
87,224 KB
testcase_16 AC 390 ms
84,212 KB
testcase_17 AC 1,034 ms
130,756 KB
testcase_18 AC 103 ms
77,184 KB
testcase_19 AC 92 ms
71,560 KB
testcase_20 AC 305 ms
82,476 KB
testcase_21 AC 1,026 ms
131,196 KB
testcase_22 AC 95 ms
72,356 KB
testcase_23 AC 746 ms
128,340 KB
testcase_24 AC 924 ms
131,220 KB
testcase_25 AC 91 ms
71,544 KB
testcase_26 AC 993 ms
129,492 KB
testcase_27 AC 989 ms
129,692 KB
testcase_28 AC 940 ms
129,232 KB
testcase_29 AC 929 ms
128,836 KB
testcase_30 AC 1,049 ms
129,636 KB
testcase_31 AC 1,033 ms
130,608 KB
testcase_32 AC 1,050 ms
129,676 KB
testcase_33 AC 1,005 ms
130,044 KB
testcase_34 AC 903 ms
128,532 KB
testcase_35 AC 963 ms
130,112 KB
testcase_36 AC 931 ms
129,136 KB
testcase_37 AC 1,036 ms
130,948 KB
testcase_38 AC 489 ms
126,432 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import gcd
from bisect import bisect_left, bisect_right
from heapq import heappop, heappush
from collections import defaultdict, deque, Counter
import sys
sys.setrecursionlimit(5*10**5)
input = sys.stdin.readline
# n <= 1<<60 以下くらい


def popcnt(n):
    c = (n & 0x5555555555555555) + ((n >> 1) & 0x5555555555555555)
    c = (c & 0x3333333333333333) + ((c >> 2) & 0x3333333333333333)
    c = (c & 0x0f0f0f0f0f0f0f0f) + ((c >> 4) & 0x0f0f0f0f0f0f0f0f)
    c = (c & 0x00ff00ff00ff00ff) + ((c >> 8) & 0x00ff00ff00ff00ff)
    c = (c & 0x0000ffff0000ffff) + ((c >> 16) & 0x0000ffff0000ffff)
    c = (c & 0x00000000ffffffff) + ((c >> 32) & 0x00000000ffffffff)
    return c


n, A, B = map(int, input().split())
ball = [list(map(int, input().split())) for i in range(n)]

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


def dist(i, j):
    xi, yi, ki = ball[i]
    xj, yj, kj = ball[j]
    return abs(xi-xj) + abs(yi-yj)

def speed(i,j):
    xi, yi, ki = ball[i]
    xj, yj, kj = ball[j]
    return abs(ki-kj)

def judge1(i, j, cnt):
    ok = 0
    if cnt == 2 and A <= dist(i, j):
        ok = 1
    if B <= speed(i,j):
        ok = 1
    return ok

def judge2(i, j, k):
    ok = 0
    if A <= dist(i,j) + dist(i,k):
        ok = 1
    return ok



ans = 1
for bit in range(1 << n):
    cnt = popcnt(bit)
    if cnt <= 1: continue
    for crr in range(n):
        if not (bit >> crr) & 1:
            continue
        for pre1 in range(n):
            if not (bit >> pre1) & 1:
                continue
            ok = judge1(crr, pre1, cnt)
            if cnt == 2 and ok:
                dp[bit][crr][pre1] |= dp[bit-(1<<crr)][pre1][-1]
                ans = max(ans, dp[bit][crr][pre1]*2)
            if cnt == 2:  continue
            for pre2 in range(n+1):
                if not (bit >> pre2) & 1:
                    continue
                if judge2(crr, pre1, pre2) or ok:
                    dp[bit][crr][pre1] |= dp[bit - (1<<crr)][pre1][pre2]
                    ans = max(ans, dp[bit][crr][pre1]*cnt)
print(ans)


0