Submission #993512
Source Code Expand
#include <cstdio> #include <cstdint> #include <algorithm> using namespace std; constexpr int MOD = 1000000007; int main() { int N, M; scanf("%d%d", &N, &M); static int dp[301][301]; for(int i = 1; i <= N; ++i) { for(int j = 1; j <= i; ++j) { dp[i][j] = 0; } } dp[1][1] = 1; for(int cnt = 0; cnt < M; ++cnt) { static int dp2[301][301]; for(int i = 1; i <= N; ++i) { for(int j = 1; j <= i; ++j) { dp2[i][j] = 0; } } for(int i = 1; i <= N; ++i) { for(int j = 1; j <= i; ++j) { dp2[i][i] = (dp2[i][i] + (int64_t)dp[i][j] * j) % MOD; dp2[i][j] = (dp2[i][j] + (int64_t)dp[i][j] * (i - j)) % MOD; if(i < N) { dp2[i+1][j] = (dp2[i+1][j] + (int64_t)dp[i][j] * (N - i)) % MOD; } } } for(int i = 1; i <= N; ++i) { for(int j = 1; j <= i; ++j) { dp[i][j] = dp2[i][j]; } } } printf("%d\n", dp[N][N]); return 0; }
Submission Info
Submission Time | |
---|---|
Task | F - Road of the King |
User | qnighy |
Language | C++14 (GCC 5.4.1) |
Score | 1000 |
Code Size | 996 Byte |
Status | AC |
Exec Time | 99 ms |
Memory | 896 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:9:34: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] int N, M; 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 | 1 ms | 128 KB |
01-02.txt | AC | 1 ms | 128 KB |
01-03.txt | AC | 1 ms | 128 KB |
01-04.txt | AC | 3 ms | 896 KB |
01-05.txt | AC | 2 ms | 128 KB |
01-06.txt | AC | 11 ms | 384 KB |
01-07.txt | AC | 93 ms | 896 KB |
01-08.txt | AC | 98 ms | 896 KB |
01-09.txt | AC | 99 ms | 896 KB |
01-10.txt | AC | 99 ms | 896 KB |
sample-01.txt | AC | 1 ms | 128 KB |
sample-02.txt | AC | 27 ms | 512 KB |
sample-03.txt | AC | 51 ms | 896 KB |