結果

問題 No.1227 I hate ThREE
ユーザー tyawanmusityawanmusi
提出日時 2020-07-28 23:03:15
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 602 bytes
コンパイル時間 88 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 251,168 KB
最終ジャッジ日時 2024-04-27 13:41:07
合計ジャッジ時間 18,727 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
17,696 KB
testcase_01 AC 31 ms
10,752 KB
testcase_02 AC 30 ms
10,752 KB
testcase_03 AC 65 ms
13,952 KB
testcase_04 AC 59 ms
11,904 KB
testcase_05 AC 149 ms
13,440 KB
testcase_06 AC 30 ms
10,752 KB
testcase_07 AC 30 ms
10,752 KB
testcase_08 AC 304 ms
16,384 KB
testcase_09 AC 237 ms
15,104 KB
testcase_10 AC 149 ms
13,312 KB
testcase_11 TLE -
testcase_12 TLE -
testcase_13 AC 54 ms
11,520 KB
testcase_14 AC 204 ms
16,512 KB
testcase_15 AC 335 ms
20,480 KB
testcase_16 AC 793 ms
34,560 KB
testcase_17 AC 458 ms
24,960 KB
testcase_18 AC 1,128 ms
45,312 KB
testcase_19 AC 880 ms
38,272 KB
testcase_20 AC 1,222 ms
47,488 KB
testcase_21 AC 36 ms
11,008 KB
testcase_22 AC 906 ms
39,424 KB
testcase_23 TLE -
testcase_24 TLE -
testcase_25 TLE -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
権限があれば一括ダウンロードができます

ソースコード

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