Submission #1051608
Source Code Expand
import java.util.*; public class Main { final static long MODULO = 1_000_000_000 + 7; public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); int M = sc.nextInt(); long[][][] dp = new long[M + 2][N + 2][N + 2];// [何日目][1を含む連結成分のサイズ][全体の訪れた町のサイズ] dp[0][1][1] = 1; for (int i = 0; i <= M; ++i) { for (int j = 0; j <= N; ++j) { for (int k = j; k <= N; ++k) { dp[i + 1][j][k] += dp[i][j][k] * (k - j); dp[i + 1][j][k] %= MODULO; dp[i + 1][k][k] += dp[i][j][k] * j; dp[i + 1][k][k] %= MODULO; dp[i + 1][j][k + 1] += dp[i][j][k] * (N - k); dp[i + 1][j][k + 1] %= MODULO; } } } System.out.println(dp[M][N][N]); } static void tr(Object... objects) { System.out.println(Arrays.deepToString(objects)); } }
Submission Info
Submission Time | |
---|---|
Task | F - Road of the King |
User | fortoobye |
Language | Java8 (OpenJDK 1.8.0) |
Score | 0 |
Code Size | 890 Byte |
Status | MLE |
Exec Time | 682 ms |
Memory | 289840 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 |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
01-01.txt | AC | 130 ms | 9680 KB |
01-02.txt | AC | 133 ms | 9808 KB |
01-03.txt | AC | 131 ms | 9804 KB |
01-04.txt | AC | 153 ms | 11860 KB |
01-05.txt | AC | 137 ms | 10060 KB |
01-06.txt | AC | 222 ms | 41452 KB |
01-07.txt | AC | 611 ms | 230452 KB |
01-08.txt | MLE | 682 ms | 289236 KB |
01-09.txt | MLE | 674 ms | 289840 KB |
01-10.txt | MLE | 672 ms | 288296 KB |
sample-01.txt | AC | 133 ms | 9680 KB |
sample-02.txt | AC | 288 ms | 70128 KB |
sample-03.txt | AC | 429 ms | 144504 KB |