結果

問題 No.1227 I hate ThREE
ユーザー tyawanmusityawanmusi
提出日時 2020-07-28 23:02:40
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 188 ms / 2,000 ms
コード長 602 bytes
コンパイル時間 658 ms
コンパイル使用メモリ 87,336 KB
実行使用メモリ 114,436 KB
最終ジャッジ日時 2023-08-30 14:33:49
合計ジャッジ時間 7,116 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,408 KB
testcase_01 AC 74 ms
71,380 KB
testcase_02 AC 75 ms
71,516 KB
testcase_03 AC 95 ms
76,724 KB
testcase_04 AC 92 ms
76,564 KB
testcase_05 AC 91 ms
76,336 KB
testcase_06 AC 74 ms
71,336 KB
testcase_07 AC 73 ms
71,380 KB
testcase_08 AC 93 ms
76,492 KB
testcase_09 AC 91 ms
76,404 KB
testcase_10 AC 88 ms
76,168 KB
testcase_11 AC 175 ms
114,112 KB
testcase_12 AC 179 ms
113,940 KB
testcase_13 AC 82 ms
75,928 KB
testcase_14 AC 87 ms
75,968 KB
testcase_15 AC 94 ms
76,040 KB
testcase_16 AC 122 ms
91,628 KB
testcase_17 AC 96 ms
76,020 KB
testcase_18 AC 135 ms
91,420 KB
testcase_19 AC 127 ms
91,384 KB
testcase_20 AC 139 ms
91,620 KB
testcase_21 AC 79 ms
75,832 KB
testcase_22 AC 127 ms
91,912 KB
testcase_23 AC 177 ms
114,284 KB
testcase_24 AC 188 ms
114,436 KB
testcase_25 AC 184 ms
114,380 KB
testcase_26 AC 179 ms
114,156 KB
testcase_27 AC 180 ms
114,392 KB
testcase_28 AC 183 ms
114,032 KB
testcase_29 AC 184 ms
114,136 KB
testcase_30 AC 178 ms
114,240 KB
testcase_31 AC 179 ms
114,212 KB
testcase_32 AC 181 ms
114,304 KB
testcase_33 AC 182 ms
114,232 KB
testcase_34 AC 180 ms
114,192 KB
testcase_35 AC 178 ms
114,264 KB
権限があれば一括ダウンロードができます

ソースコード

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))%mod)
0