結果

問題 No.2375 watasou and hibit's baseball
ユーザー mkawa2mkawa2
提出日時 2023-07-07 22:31:43
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 468 ms / 2,000 ms
コード長 1,603 bytes
コンパイル時間 1,539 ms
コンパイル使用メモリ 86,768 KB
実行使用メモリ 121,204 KB
最終ジャッジ日時 2023-09-29 00:00:01
合計ジャッジ時間 9,946 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 79 ms
71,432 KB
testcase_01 AC 79 ms
71,264 KB
testcase_02 AC 79 ms
71,272 KB
testcase_03 AC 215 ms
96,796 KB
testcase_04 AC 85 ms
76,160 KB
testcase_05 AC 86 ms
75,820 KB
testcase_06 AC 468 ms
121,084 KB
testcase_07 AC 78 ms
71,252 KB
testcase_08 AC 130 ms
85,332 KB
testcase_09 AC 77 ms
71,396 KB
testcase_10 AC 77 ms
71,424 KB
testcase_11 AC 95 ms
76,720 KB
testcase_12 AC 255 ms
120,896 KB
testcase_13 AC 173 ms
96,960 KB
testcase_14 AC 78 ms
71,572 KB
testcase_15 AC 154 ms
81,972 KB
testcase_16 AC 133 ms
78,908 KB
testcase_17 AC 240 ms
121,064 KB
testcase_18 AC 78 ms
71,072 KB
testcase_19 AC 79 ms
71,036 KB
testcase_20 AC 97 ms
76,692 KB
testcase_21 AC 244 ms
121,136 KB
testcase_22 AC 77 ms
71,328 KB
testcase_23 AC 219 ms
120,780 KB
testcase_24 AC 219 ms
120,476 KB
testcase_25 AC 78 ms
71,376 KB
testcase_26 AC 301 ms
121,064 KB
testcase_27 AC 316 ms
121,104 KB
testcase_28 AC 337 ms
121,064 KB
testcase_29 AC 338 ms
121,100 KB
testcase_30 AC 366 ms
120,924 KB
testcase_31 AC 352 ms
121,184 KB
testcase_32 AC 384 ms
121,092 KB
testcase_33 AC 322 ms
121,068 KB
testcase_34 AC 309 ms
121,204 KB
testcase_35 AC 357 ms
121,120 KB
testcase_36 AC 353 ms
121,100 KB
testcase_37 AC 317 ms
121,128 KB
testcase_38 AC 233 ms
120,848 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

# sys.setrecursionlimit(200005)
# sys.set_int_max_str_digits(1000005)
int1 = lambda x: int(x)-1
pDB = lambda *x: print(*x, end="\n", file=sys.stderr)
p2D = lambda x: print(*x, sep="\n", end="\n\n", file=sys.stderr)
def II(): return int(sys.stdin.readline())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
def SI(): return sys.stdin.readline().rstrip()

dij = [(0, 1), (-1, 0), (0, -1), (1, 0)]
# dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
inf = (1 << 63)-1
# md = 10**9+7
md = 998244353

def popcnt(a): return bin(a).count("1")

n,a,b=LI()
xyk=LLI(n)
dd=[[0]*n for _ in range(n)]
for i,(x,y,k) in enumerate(xyk):
    for j,(s,t,_) in enumerate(xyk[:i]):
        dd[i][j]=dd[j][i]=abs(s-x)+abs(t-y)

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

ans=0
for s in range(1,1<<n):
    p=popcnt(s)
    for i in range(n):
        if s>>i&1==0:continue
        for j in range(n):
            if s>>j&1==0:continue
            if dp[s][i][j]==0:continue
            ans=max(ans,p)
            for k in range(n):
                ns=s|1<<k
                if ns==s:continue
                val=0
                if p==1 and dd[j][k]>=a:val=1
                if val==0 and abs(xyk[j][2]-xyk[k][2])>=b:val=1
                if val==0 and p>=2 and dd[i][k]+dd[j][k]>=a:val=1
                dp[ns][j][k]|=val

print(ans)
0