Submission #1352063
Source Code Expand
#include<iostream> #include<algorithm> using namespace std; long long n, m, dp[305][305][305], mod = 1000000007; long long solve(long long pos, long long rec1, long long rec2) { if (rec1 + rec2 > n)return 0; if (pos == m) { if (rec1 == n && rec2 == 0)return 1; return 0; } if (dp[pos][rec1][rec2] >= 1)return dp[pos][rec1][rec2] - 1; long long ret = 0; ret += solve(pos + 1, rec1 + rec2, 0)*rec1; ret += solve(pos + 1, rec1, rec2)*rec2; ret += solve(pos + 1, rec1, rec2 + 1)*(n - rec1 - rec2); ret %= mod; dp[pos][rec1][rec2] = ret + 1; return ret; } int main() { cin >> n >> m; cout << solve(0, 1, 0) << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | F - Road of the King |
User | E869120 |
Language | C++14 (GCC 5.4.1) |
Score | 1000 |
Code Size | 661 Byte |
Status | AC |
Exec Time | 196 ms |
Memory | 217344 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, 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 | 43 ms | 217344 KB |
01-04.txt | AC | 1 ms | 256 KB |
01-05.txt | AC | 43 ms | 217344 KB |
01-06.txt | AC | 75 ms | 217344 KB |
01-07.txt | AC | 193 ms | 217344 KB |
01-08.txt | AC | 195 ms | 217344 KB |
01-09.txt | AC | 196 ms | 217344 KB |
01-10.txt | AC | 195 ms | 217344 KB |
sample-01.txt | AC | 1 ms | 256 KB |
sample-02.txt | AC | 121 ms | 217344 KB |
sample-03.txt | AC | 41 ms | 108800 KB |