Submission #993463
Source Code Expand
import java.util.Scanner; public class Main { public static long MOD = 1000000007; public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int m = sc.nextInt(); long[][] dp = new long[n+1][n+1]; dp[1][0] = 1; for(int i=0;i<m;i++) { long[][] next = new long[n+1][n+1]; for(int a=0;a<=n;a++) { for(int b=0;b<=n;b++) { if (dp[a][b] == 0) continue; next[a+b][0] = (next[a+b][0] + dp[a][b] * a) % MOD; next[a][b+1] = (next[a][b+1] + dp[a][b] * (n-a-b)) % MOD; next[a][b] = (next[a][b] + dp[a][b] * b) % MOD; } } dp = next; } System.out.println(dp[n][0]); } }
Submission Info
Submission Time | |
---|---|
Task | F - Road of the King |
User | piroz95 |
Language | Java8 (OpenJDK 1.8.0) |
Score | 1000 |
Code Size | 685 Byte |
Status | AC |
Exec Time | 437 ms |
Memory | 75468 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 |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
01-01.txt | AC | 123 ms | 9552 KB |
01-02.txt | AC | 124 ms | 9680 KB |
01-03.txt | AC | 126 ms | 9808 KB |
01-04.txt | AC | 128 ms | 11088 KB |
01-05.txt | AC | 130 ms | 10068 KB |
01-06.txt | AC | 189 ms | 25300 KB |
01-07.txt | AC | 425 ms | 73804 KB |
01-08.txt | AC | 435 ms | 73800 KB |
01-09.txt | AC | 432 ms | 74184 KB |
01-10.txt | AC | 437 ms | 75468 KB |
sample-01.txt | AC | 125 ms | 9680 KB |
sample-02.txt | AC | 248 ms | 26308 KB |
sample-03.txt | AC | 234 ms | 44756 KB |