Submission #992879
Source Code Expand
#include <algorithm> #include <cassert> #include <cctype> #include <cstdlib> #include <cmath> #include <cstdio> #include <functional> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <string> #include <unordered_map> #include <unordered_set> #include <vector> #include <utility> #define reps(i,f,n) for(int i=f; i<int(n); ++i) #define rep(i,n) reps(i,0,n) using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<vi> vvi; typedef pair<int, int> pii; const int MOD = 1000000007; signed main() { int n, m; cin >> n >> m; vvi dp(n+1, vi(n+1)); dp[1][0] = 1; rep(i, m){ vvi next(n+1, vi(n+1)); rep(a, n+1) rep(b, n+1){ if(a+b > n) continue; next[a+b][0] = (next[a+b][0] + dp[a][b] * ll(a)) % MOD; next[a][b] = (next[a][b] + dp[a][b] * ll(b)) % MOD; if(b+1 <= n) next[a][b+1] = (next[a][b+1] + dp[a][b] * ll(n-a-b)) % MOD; } swap(dp, next); } cout << dp[n][0] << endl; }
Submission Info
Submission Time | |
---|---|
Task | F - Road of the King |
User | natrium |
Language | C++14 (GCC 5.4.1) |
Score | 1000 |
Code Size | 1156 Byte |
Status | AC |
Exec Time | 171 ms |
Memory | 1028 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 | 3 ms | 256 KB |
01-02.txt | AC | 3 ms | 256 KB |
01-03.txt | AC | 3 ms | 256 KB |
01-04.txt | AC | 4 ms | 1024 KB |
01-05.txt | AC | 3 ms | 256 KB |
01-06.txt | AC | 16 ms | 256 KB |
01-07.txt | AC | 160 ms | 976 KB |
01-08.txt | AC | 169 ms | 1020 KB |
01-09.txt | AC | 171 ms | 1020 KB |
01-10.txt | AC | 171 ms | 1028 KB |
sample-01.txt | AC | 2 ms | 256 KB |
sample-02.txt | AC | 37 ms | 384 KB |
sample-03.txt | AC | 87 ms | 1028 KB |