Submission #2125871
Source Code Expand
#include <bits/stdc++.h> using namespace std; const int N = 305; const int mod = 1e9 + 7; int n, m, dp[N][N][N]; void add(int &x, int y) { x += y; while(x >= mod) x -= mod; while(x < 0) x += mod; } int main() { ios_base::sync_with_stdio(false); cin.tie(0); cin >> n >> m; dp[0][1][1] = 1; for (int i = 0; i < m; ++i) { for (int j = 1; j <= n; ++j) { for (int k = 1; k <= j; ++k) { if (!dp[i][j][k]) continue; add(dp[i + 1][j + 1][k], 1LL * dp[i][j][k] * (n - j) % mod); add(dp[i + 1][j][k], 1LL * dp[i][j][k] * (j - k) % mod); add(dp[i + 1][j][j], 1LL * dp[i][j][k] * k % mod); } } } cout << dp[m][n][n] << endl; }
Submission Info
Submission Time | |
---|---|
Task | F - Road of the King |
User | cheater2k |
Language | C++14 (GCC 5.4.1) |
Score | 1000 |
Code Size | 787 Byte |
Status | AC |
Exec Time | 104 ms |
Memory | 108800 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 | 23 ms | 108800 KB |
01-04.txt | AC | 1 ms | 256 KB |
01-05.txt | AC | 22 ms | 108800 KB |
01-06.txt | AC | 39 ms | 108800 KB |
01-07.txt | AC | 102 ms | 108800 KB |
01-08.txt | AC | 104 ms | 108800 KB |
01-09.txt | AC | 104 ms | 108800 KB |
01-10.txt | AC | 104 ms | 108800 KB |
sample-01.txt | AC | 1 ms | 256 KB |
sample-02.txt | AC | 61 ms | 108800 KB |
sample-03.txt | AC | 26 ms | 53504 KB |