結果

問題 No.1227 I hate ThREE
ユーザー tyawanmusityawanmusi
提出日時 2020-07-28 23:01:42
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 596 bytes
コンパイル時間 87 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 244,352 KB
最終ジャッジ日時 2024-04-27 13:40:14
合計ジャッジ時間 41,275 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

import sys
sys.setrecursionlimit(2000)
input=sys.stdin.readline
mod=10**9+7
n,c=map(int,input().split())
minc=min(n*6-5,c)
edge=[[]for _ in range(n)]
for _ in range(n-1):
  a,b=map(int,input().split())
  a-=1
  b-=1
  edge[a].append(b)
  edge[b].append(a)
dp=[minc*[1]for _ in range(n)]
def dfs(r,node):
  for mode in edge[node]:
    if r==mode:continue
    dpsub=dfs(node,mode)
    for i in range(minc):
      f=0
      if i>2:f+=dpsub[i-3]
      if i<minc-3:f+=dpsub[i+3]
      dp[node][i]*=f
      dp[node][i]%=mod
  return dp[node]
lastdp=dfs(-1,0)
print(sum(lastdp)+lastdp[minc//2]*(c-minc))
0