Submission #5026731
Source Code Expand
#include <bits/stdc++.h> using namespace std; const int N = 305; const int MOD = 1e9 + 7; int dp[N][N][N]; int n, m; int main() { scanf("%d%d", &n, &m); dp[0][1][0] = 1; for (int i = 0; i < m; i++) { for (int j = 1; j <= min(n, m); j++) { for (int k = 0; j + k <= min(n, m); k++) { if (!dp[i][j][k]) continue; dp[i + 1][j + k][0] = (dp[i + 1][j + k][0] + 1LL * dp[i][j][k] * j) % MOD; dp[i + 1][j][k + 1] = (dp[i + 1][j][k + 1] + 1LL * dp[i][j][k] * (n - j - k)) % MOD; dp[i + 1][j][k] = (dp[i + 1][j][k] + 1LL * dp[i][j][k] * k) % MOD; //printf("(%d,%d,%d):[%d]\n", i, j, k, dp[i][j][k]); } } } printf("%d\n", dp[m][n][0]); return 0; }
Submission Info
Submission Time | |
---|---|
Task | F - Road of the King |
User | vjudge4 |
Language | C++14 (GCC 5.4.1) |
Score | 1000 |
Code Size | 860 Byte |
Status | AC |
Exec Time | 63 ms |
Memory | 108800 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:8:26: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d%d", &n, &m); ^
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 | 1 ms | 256 KB |
01-02.txt | AC | 1 ms | 256 KB |
01-03.txt | AC | 22 ms | 108800 KB |
01-04.txt | AC | 1 ms | 256 KB |
01-05.txt | AC | 22 ms | 108800 KB |
01-06.txt | AC | 30 ms | 108800 KB |
01-07.txt | AC | 62 ms | 108800 KB |
01-08.txt | AC | 63 ms | 108800 KB |
01-09.txt | AC | 63 ms | 108800 KB |
01-10.txt | AC | 63 ms | 108800 KB |
sample-01.txt | AC | 1 ms | 256 KB |
sample-02.txt | AC | 40 ms | 108800 KB |
sample-03.txt | AC | 17 ms | 53504 KB |