結果

問題 No.2375 watasou and hibit's baseball
ユーザー flygonflygon
提出日時 2023-07-07 22:33:32
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 2,029 bytes
コンパイル時間 395 ms
コンパイル使用メモリ 87,052 KB
実行使用メモリ 132,124 KB
最終ジャッジ日時 2023-09-29 00:03:31
合計ジャッジ時間 26,750 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 101 ms
71,636 KB
testcase_01 AC 103 ms
71,540 KB
testcase_02 AC 103 ms
72,068 KB
testcase_03 AC 703 ms
105,056 KB
testcase_04 WA -
testcase_05 AC 142 ms
77,288 KB
testcase_06 AC 1,207 ms
131,032 KB
testcase_07 AC 102 ms
71,776 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 1,073 ms
130,044 KB
testcase_13 WA -
testcase_14 AC 105 ms
71,420 KB
testcase_15 AC 537 ms
88,212 KB
testcase_16 AC 422 ms
83,552 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 103 ms
71,552 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 102 ms
72,288 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 1,064 ms
130,256 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 1,130 ms
130,796 KB
testcase_34 WA -
testcase_35 AC 1,017 ms
129,660 KB
testcase_36 AC 1,022 ms
129,172 KB
testcase_37 WA -
testcase_38 WA -
権限があれば一括ダウンロードができます

ソースコード

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)
            for pre2 in range(n+1):
                if ok:
                    dp[bit][crr][pre1] |= dp[bit - (1<<crr)][pre1][pre2]
                    ans = max(ans, cnt)
                if not (bit >> pre2) & 1:
                    continue
                if judge2(crr, pre1, pre2):
                    dp[bit][crr][pre1] |= dp[bit - (1<<crr)][pre1][pre2]
                    ans = max(ans, cnt)
print(ans)


0