結果

問題 No.196 典型DP (1)
ユーザー yaoshimaxyaoshimax
提出日時 2015-05-16 10:57:31
言語 PyPy2
(7.3.15)
結果
WA  
実行時間 -
コード長 714 bytes
コンパイル時間 1,200 ms
コンパイル使用メモリ 77,736 KB
実行使用メモリ 836,828 KB
最終ジャッジ日時 2023-09-20 09:07:09
合計ジャッジ時間 10,278 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 79 ms
76,520 KB
testcase_01 AC 78 ms
76,516 KB
testcase_02 AC 77 ms
76,476 KB
testcase_03 AC 79 ms
76,332 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 78 ms
76,612 KB
testcase_08 AC 78 ms
76,292 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 81 ms
77,028 KB
testcase_12 WA -
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 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 186 ms
111,960 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 MLE -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

N,K=map(int,raw_input().split())
parent=[-1 for i in range(N)]
child=[[] for i in range(N)]
mod=1000000007
for i in range(N-1):
    a,b=map(int,raw_input().split())
    parent[b]=a
    child[a].append(b)
dp=[[0 for j in range(N+1)] for k in range(N)]
for i in range(N-1,-1,-1):
    if len(child[i])==0:
        dp[i][0]=1
        dp[i][1]=1
        continue
    l=[(0,1)]
    for c in child[i]:
        nl=[]
        for j in range(N+1):
            if dp[c][j]==0:
                break
            for key,val in l:
                nl.append((key+j,val*dp[c][j]%mod))
        l=nl
    s=0
    for key,val in l:
        dp[i][key]+=val
        dp[i][key]%=mod
        s=max(s,key)
    dp[i][s+1]=1
print dp[0][K]
0