Submission #1007696
Source Code Expand
#include <bits/stdc++.h> using namespace std; typedef long long LL; #define mod 1000000007 #define MAX_N 305 #define MAX_M 305 int N, M; void input() { cin >> N >> M; } //パスの長さ パスに含まれる頂点の数 強連結の数 LL dp[MAX_N][MAX_N][MAX_N]; LL solve() { memset(dp, 0, sizeof(dp)); dp[0][1][1] = 1; for (int i = 0; i < M; i++) { for (int j = 0; j <= N; j++) { for (int k = 0; k <= N; k++) { dp[i+1][j+1][k] += dp[i][j][k] * (N-j); dp[i+1][j+1][k] %= mod; if(j >= k){ dp[i+1][j][k] += dp[i][j][k] * (j-k); dp[i+1][j][k] %= mod; } dp[i+1][j][j] += dp[i][j][k]*k; dp[i+1][j][j] %= mod; } } } return dp[M][N][N]; } int main() { input(); cout << solve() << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | F - Road of the King |
User | takoshi |
Language | C++14 (GCC 5.4.1) |
Score | 1000 |
Code Size | 868 Byte |
Status | AC |
Exec Time | 410 ms |
Memory | 221952 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 | 246 ms | 221952 KB |
01-02.txt | AC | 244 ms | 221952 KB |
01-03.txt | AC | 246 ms | 221952 KB |
01-04.txt | AC | 247 ms | 221952 KB |
01-05.txt | AC | 247 ms | 221952 KB |
01-06.txt | AC | 264 ms | 221952 KB |
01-07.txt | AC | 396 ms | 221952 KB |
01-08.txt | AC | 405 ms | 221952 KB |
01-09.txt | AC | 408 ms | 221952 KB |
01-10.txt | AC | 410 ms | 221952 KB |
sample-01.txt | AC | 246 ms | 221952 KB |
sample-02.txt | AC | 291 ms | 221952 KB |
sample-03.txt | AC | 326 ms | 221952 KB |