Submission #1799778
Source Code Expand
#include <bits/stdc++.h> using namespace std; #define for_(i,a,b) for(int i=(a);i<(b);++i) typedef long long lint; template< typename T > void modAdd(T& a, T b, T mod) { a = (a+b)%mod; } int N, M; lint dp[302][302][302]; const lint MOD = (lint)1e9 + 7; int main() { cin >> N >> M; memset(dp, 0, sizeof(dp)); dp[0][1][0] = 1; for_(i,0,M) for_(c,0,N+1) for_(s,0,N) { if (c+s <= N) { modAdd(dp[i+1][c+s][0], dp[i][c][s] * lint(c), MOD); modAdd(dp[i+1][c][s], dp[i][c][s] * lint(s), MOD); } if (c+s+1 <= N) modAdd(dp[i+1][c][s+1], dp[i][c][s] * lint(N-c-s), MOD); } cout << dp[M][N][0] << endl; }
Submission Info
Submission Time | |
---|---|
Task | F - Road of the King |
User | tsukasa_diary |
Language | C++14 (GCC 5.4.1) |
Score | 1000 |
Code Size | 636 Byte |
Status | AC |
Exec Time | 173 ms |
Memory | 215424 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 | 53 ms | 215424 KB |
01-02.txt | AC | 53 ms | 215424 KB |
01-03.txt | AC | 53 ms | 215424 KB |
01-04.txt | AC | 54 ms | 215424 KB |
01-05.txt | AC | 54 ms | 215424 KB |
01-06.txt | AC | 65 ms | 215424 KB |
01-07.txt | AC | 165 ms | 215424 KB |
01-08.txt | AC | 172 ms | 215424 KB |
01-09.txt | AC | 172 ms | 215424 KB |
01-10.txt | AC | 173 ms | 215424 KB |
sample-01.txt | AC | 53 ms | 215424 KB |
sample-02.txt | AC | 86 ms | 215424 KB |
sample-03.txt | AC | 113 ms | 215424 KB |