Submission #1228497


Source Code Expand

n, m = map(int,raw_input().split())
mod = 10 ** 9 + 7
dp=[[[0] * (n + 1) for _ in xrange(n + 1)] for _ in xrange(m + 1)]
dp[0][1][1] = 1
for i in xrange(m):
    for j in xrange(1, n + 1):
        for k in xrange(1, j + 1):
            dp[i+1][min(j+1,n)][k] += dp[i][j][k] * (n - j)  % mod
            dp[i+1][j][k] += dp[i][j][k] * (j - k) % mod
            dp[i+1][j][j] += dp[i][j][k] * k % mod
print dp[m][n][n] % mod

Submission Info

Submission Time
Task F - Road of the King
User roto_37
Language PyPy2 (5.6.0)
Score 0
Code Size 433 Byte
Status MLE
Exec Time 759 ms
Memory 254236 KB

Judge Result

Set Name sample all
Score / Max Score 0 / 0 0 / 1000
Status
AC × 3
AC × 12
MLE × 4
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 37 ms 28012 KB
01-02.txt AC 34 ms 26860 KB
01-03.txt AC 38 ms 28524 KB
01-04.txt AC 59 ms 34156 KB
01-05.txt AC 64 ms 33388 KB
01-06.txt AC 138 ms 54044 KB
01-07.txt MLE 711 ms 239260 KB
01-08.txt MLE 755 ms 251420 KB
01-09.txt MLE 753 ms 253596 KB
01-10.txt MLE 759 ms 254236 KB
sample-01.txt AC 34 ms 26604 KB
sample-02.txt AC 250 ms 90140 KB
sample-03.txt AC 408 ms 144156 KB