Submission #1799872
Source Code Expand
import java.util.*; class Main { static final long MOD=1000000007; public static void main(String[] args) { Scanner scan = new Scanner(System.in); int n=scan.nextInt(); int m=scan.nextInt(); long[][][]dp=new long[m+1][n][n]; dp[0][0][0]=1; for(int i=0;i<m;++i){ for(int j=0;j<n;++j) for(int k=0;k<n;++k){ if(j<n-1){ dp[i+1][j+1][k]+=dp[i][j][k]; dp[i+1][j+1][k]%=MOD; } dp[i+1][j][j]+=(k+1)*dp[i][j][k]; dp[i+1][j][j]%=MOD; dp[i+1][j][k]+=(j-k)*dp[i][j][k]; dp[i+1][j][k]%=MOD; } } long t=0; for(int i=0;i<n;++i) t=(t+dp[m][i][n-1])%MOD; for(int i=1;i<=n-1;++i) t=t*i%MOD; System.out.println(t); } }
Submission Info
Submission Time | |
---|---|
Task | F - Road of the King |
User | kirika_comp |
Language | Java8 (OpenJDK 1.8.0) |
Score | 0 |
Code Size | 968 Byte |
Status | MLE |
Exec Time | 710 ms |
Memory | 302804 KB |
Judge Result
Set Name | sample | all | ||||||
---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 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 | 92 ms | 18896 KB |
01-02.txt | AC | 91 ms | 23636 KB |
01-03.txt | AC | 93 ms | 21716 KB |
01-04.txt | AC | 113 ms | 21972 KB |
01-05.txt | AC | 100 ms | 19796 KB |
01-06.txt | AC | 171 ms | 54100 KB |
01-07.txt | MLE | 675 ms | 299164 KB |
01-08.txt | MLE | 705 ms | 302804 KB |
01-09.txt | MLE | 699 ms | 302400 KB |
01-10.txt | MLE | 710 ms | 302804 KB |
sample-01.txt | AC | 92 ms | 19284 KB |
sample-02.txt | AC | 273 ms | 86756 KB |
sample-03.txt | AC | 426 ms | 164028 KB |