Submission #1004233
Source Code Expand
#include <iostream> #include <vector> #include <string> #include <cmath> #include <algorithm> using namespace std; #define mod 1000000007 int main(){ long long dp[301][301][301]={}; int n,m; cin >> n >> m; dp[0][1][1]=1; for(int i=1;i<=m;i++){ for(int j=1;j<=n;j++){ for(int k=1;k<=n;k++){ if(j==k){ for(int l=1;l<=k;l++){ dp[i][j][k] = (dp[i][j][k]+l*dp[i-1][j][l])%mod; } }else{ dp[i][j][k] = (dp[i][j][k]+(n-j+1)*dp[i-1][j-1][k]+(j-k)*dp[i-1][j][k])%mod; } } } } cout << dp[m][n][n] << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | F - Road of the King |
User | mtsd |
Language | C++14 (GCC 5.4.1) |
Score | 1000 |
Code Size | 587 Byte |
Status | AC |
Exec Time | 339 ms |
Memory | 213248 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 | 204 ms | 213248 KB |
01-02.txt | AC | 204 ms | 213248 KB |
01-03.txt | AC | 205 ms | 213248 KB |
01-04.txt | AC | 204 ms | 213248 KB |
01-05.txt | AC | 205 ms | 213248 KB |
01-06.txt | AC | 220 ms | 213248 KB |
01-07.txt | AC | 330 ms | 213248 KB |
01-08.txt | AC | 337 ms | 213248 KB |
01-09.txt | AC | 339 ms | 213248 KB |
01-10.txt | AC | 339 ms | 213248 KB |
sample-01.txt | AC | 205 ms | 213248 KB |
sample-02.txt | AC | 241 ms | 213248 KB |
sample-03.txt | AC | 273 ms | 213248 KB |