結果

問題 No.1227 I hate ThREE
ユーザー tyawanmusityawanmusi
提出日時 2020-08-23 18:12:51
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 602 bytes
コンパイル時間 204 ms
コンパイル使用メモリ 82,784 KB
実行使用メモリ 115,184 KB
最終ジャッジ日時 2024-04-27 13:41:18
合計ジャッジ時間 4,304 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
53,688 KB
testcase_01 AC 34 ms
51,936 KB
testcase_02 AC 34 ms
53,220 KB
testcase_03 AC 50 ms
67,504 KB
testcase_04 AC 51 ms
66,836 KB
testcase_05 AC 51 ms
67,452 KB
testcase_06 AC 35 ms
52,736 KB
testcase_07 WA -
testcase_08 AC 53 ms
68,400 KB
testcase_09 AC 56 ms
67,404 KB
testcase_10 AC 48 ms
65,116 KB
testcase_11 AC 127 ms
114,400 KB
testcase_12 AC 132 ms
115,184 KB
testcase_13 AC 41 ms
61,772 KB
testcase_14 AC 49 ms
66,156 KB
testcase_15 AC 52 ms
68,752 KB
testcase_16 AC 80 ms
92,108 KB
testcase_17 AC 57 ms
72,708 KB
testcase_18 AC 92 ms
91,848 KB
testcase_19 AC 87 ms
92,264 KB
testcase_20 AC 97 ms
91,936 KB
testcase_21 AC 38 ms
60,340 KB
testcase_22 AC 88 ms
91,916 KB
testcase_23 WA -
testcase_24 AC 137 ms
114,804 KB
testcase_25 WA -
testcase_26 AC 136 ms
114,408 KB
testcase_27 AC 136 ms
114,668 KB
testcase_28 AC 135 ms
114,568 KB
testcase_29 AC 140 ms
114,508 KB
testcase_30 AC 134 ms
114,344 KB
testcase_31 AC 133 ms
114,516 KB
testcase_32 AC 136 ms
114,528 KB
testcase_33 AC 137 ms
114,492 KB
testcase_34 AC 138 ms
114,524 KB
testcase_35 AC 131 ms
114,668 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-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