Submission #992457
Source Code Expand
#include <cstdio> #include <algorithm> #include <vector> #include <stack> #include <queue> #include <set> #include <map> #include <cstring> #include <string> #include <cmath> #include <cstdlib> #include <iostream> using namespace std; #define MOD 1000000007 #define ADD(X,Y) ((X) = ((X) + (Y)) % MOD) typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec; int N, M; i64 dp[303][303][303]; // day, unvis, size of 0 unit int main() { scanf("%d%d", &N, &M); for (int i = 0; i <= M; ++i) { for (int j = 0; j <= N; ++j) { for (int k = 0; k <= N; ++k) { dp[i][j][k] = 0; } } } dp[0][N - 1][1] = 1; for (int i = 0; i < M; ++i) { for (int j = 0; j <= N; ++j) { for (int k = 0; k <= N; ++k) if (dp[i][j][k]) { ADD(dp[i + 1][j][N - j], k * dp[i][j][k]); if (j > 0) ADD(dp[i + 1][j - 1][k], j * dp[i][j][k]); ADD(dp[i + 1][j][k], (N - k - j) * dp[i][j][k]); } } } printf("%lld\n", dp[M][0][N]); return 0; }
Submission Info
Submission Time | |
---|---|
Task | F - Road of the King |
User | semiexp |
Language | C++14 (GCC 5.4.1) |
Score | 1000 |
Code Size | 1012 Byte |
Status | AC |
Exec Time | 259 ms |
Memory | 215936 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:25:23: 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 |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
01-01.txt | AC | 3 ms | 256 KB |
01-02.txt | AC | 2 ms | 256 KB |
01-03.txt | AC | 6 ms | 2816 KB |
01-04.txt | AC | 4 ms | 1664 KB |
01-05.txt | AC | 11 ms | 8576 KB |
01-06.txt | AC | 74 ms | 65024 KB |
01-07.txt | AC | 250 ms | 208128 KB |
01-08.txt | AC | 257 ms | 214528 KB |
01-09.txt | AC | 259 ms | 215168 KB |
01-10.txt | AC | 259 ms | 215936 KB |
sample-01.txt | AC | 3 ms | 256 KB |
sample-02.txt | AC | 127 ms | 108672 KB |
sample-03.txt | AC | 121 ms | 108416 KB |