Submission #3874572


Source Code Expand

input = raw_input
range = xrange
n, m = map(int,input().split())
MOD = 10**9+7

dp = [[0]*(n) for i in range(n+1)]
dp[1][0] = 1
for i in range(m):
    new = [[0]*(n) for i in range(n+1)]
    for j in range(1, n+1):
        for k in range(n-j+1):
            pv = dp[j][k]
            if k != n-j: new[j][k+1] = (new[j][k+1] + pv * (n-j-k)) % MOD
            new[j][k] = (new[j][k] + pv * k) % MOD
            new[j+k][0] = (new[j+k][0] + pv * j) % MOD
    dp = new
print(dp[n][0])

Submission Info

Submission Time
Task F - Road of the King
User jh05013
Language PyPy2 (5.6.0)
Score 1000
Code Size 496 Byte
Status AC
Exec Time 473 ms
Memory 60060 KB

Judge Result

Set Name sample all
Score / Max Score 0 / 0 1000 / 1000
Status
AC × 3
AC × 16
Set Name Test Cases
sample sample-01.txt, sample-02.txt, sample-03.txt
all sample-01.txt, sample-02.txt, sample-03.txt, 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt, sample-01.txt, sample-02.txt, sample-03.txt
Case Name Status Exec Time Memory
01-01.txt AC 40 ms 26860 KB
01-02.txt AC 37 ms 26860 KB
01-03.txt AC 41 ms 29164 KB
01-04.txt AC 66 ms 34284 KB
01-05.txt AC 62 ms 32748 KB
01-06.txt AC 107 ms 33640 KB
01-07.txt AC 440 ms 56732 KB
01-08.txt AC 462 ms 59292 KB
01-09.txt AC 463 ms 59548 KB
01-10.txt AC 473 ms 60060 KB
sample-01.txt AC 38 ms 26860 KB
sample-02.txt AC 165 ms 34716 KB
sample-03.txt AC 269 ms 46620 KB