Submission #1832945
Source Code Expand
#include <bits/stdc++.h> using namespace std; #define ll long long const int N = 303; const int inf = (int)1e9 + 7; int dp[N][N][N]; int mult (int a, int b) { return a * 1LL * b % inf; } int add (int a, int b) { a += b; if (a >= inf) a -= inf; return a; } main() { int n, m; scanf ("%d %d", &n, &m); dp[0][1][1] = 1; for (int i = 0; i < m; i++) { for (int j = 1; j <= n; j++) { for (int l = 1; l <= n; l++) { int delta = dp[i][j][l]; if (delta == 0) continue; dp[i + 1][j + 1][l] = add(mult(delta,(n - j)), dp[i + 1][j + 1][l]); dp[i + 1][j][l] = add(mult(delta, j - l),dp[i + 1][j][l]); dp[i + 1][j][j] = add(mult(delta, l), dp[i + 1][j][j]); } } } cout << dp[m][n][n]; }
Submission Info
Submission Time | |
---|---|
Task | F - Road of the King |
User | vjudge2 |
Language | C++14 (GCC 5.4.1) |
Score | 1000 |
Code Size | 836 Byte |
Status | AC |
Exec Time | 75 ms |
Memory | 106752 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:23:38: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] int n, m; scanf ("%d %d", &n, &m); ^
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 | 27 ms | 106752 KB |
01-04.txt | AC | 1 ms | 256 KB |
01-05.txt | AC | 26 ms | 106752 KB |
01-06.txt | AC | 35 ms | 106752 KB |
01-07.txt | AC | 74 ms | 106752 KB |
01-08.txt | AC | 75 ms | 106752 KB |
01-09.txt | AC | 75 ms | 106752 KB |
01-10.txt | AC | 75 ms | 106752 KB |
sample-01.txt | AC | 1 ms | 256 KB |
sample-02.txt | AC | 46 ms | 106752 KB |
sample-03.txt | AC | 28 ms | 53504 KB |