Submission #1228519
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(2)] dp[0][1][1] = 1 for i in xrange(m): for j in xrange(n + 1): for k in xrange(n + 1): dp[(i+1)%2][j][k] = 0 for j in xrange(1, n + 1): for k in xrange(1, j + 1): dp[(i+1)%2][min(j+1,n)][k] += dp[i%2][j][k] * (n - j) % mod dp[(i+1)%2][j][k] += dp[i%2][j][k] * (j - k) % mod dp[(i+1)%2][j][j] += dp[i%2][j][k] * k % mod print dp[m%2][n][n] % mod
Submission Info
Submission Time | |
---|---|
Task | F - Road of the King |
User | roto_37 |
Language | PyPy2 (5.6.0) |
Score | 1000 |
Code Size | 545 Byte |
Status | AC |
Exec Time | 781 ms |
Memory | 34920 KB |
Judge Result
Set Name | sample | all | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 1000 / 1000 | ||||
Status |
|
|
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 | 42 ms | 26988 KB |
01-02.txt | AC | 37 ms | 28396 KB |
01-03.txt | AC | 98 ms | 33388 KB |
01-04.txt | AC | 63 ms | 34540 KB |
01-05.txt | AC | 67 ms | 32492 KB |
01-06.txt | AC | 138 ms | 33004 KB |
01-07.txt | AC | 736 ms | 34920 KB |
01-08.txt | AC | 773 ms | 34920 KB |
01-09.txt | AC | 776 ms | 34920 KB |
01-10.txt | AC | 781 ms | 34920 KB |
sample-01.txt | AC | 37 ms | 27372 KB |
sample-02.txt | AC | 258 ms | 33512 KB |
sample-03.txt | AC | 434 ms | 34920 KB |