結果

問題 No.1227 I hate ThREE
ユーザー tyawanmusi
提出日時 2020-08-23 18:12:51
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 602 bytes
コンパイル時間 501 ms
コンパイル使用メモリ 82,728 KB
実行使用メモリ 115,200 KB
最終ジャッジ日時 2024-11-15 15:53:38
合計ジャッジ時間 4,930 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 30 WA * 3
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
sys.setrecursionlimit(2000)
input=sys.stdin.readline
mod=10**9+7
n,c=map(int,input().split())
minc=min(n*6-6,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))%mod)
0