Submission #1832942
Source Code Expand
#include <bits/stdc++.h> using namespace std; const int md = 1000000007; inline void add(int &a, int b) { a += b; if (a >= md) a -= md; } inline int mul(int a, int b) { return (long long) a * b % md; } const int N = 303; int f[N][N][N]; int main() { int n, m; scanf("%d %d", &n, &m); f[0][1][1] = 1; int ans = 0; for (int i = 0; i < m; i++) { for (int vis = 1; vis <= n; vis++) { for (int cap = 1; cap <= n; cap++) { int ft = f[i][vis][cap]; if (ft == 0) { continue; } if (i < m - 1) { add(f[i + 1][vis + 1][cap], mul(ft, n - vis)); add(f[i + 1][vis][vis], mul(ft, cap)); add(f[i + 1][vis][cap], mul(ft, vis - cap)); } else { if (vis == n) { add(ans, mul(ft, cap)); } } } } } printf("%d\n", ans); return 0; }
Submission Info
Submission Time | |
---|---|
Task | F - Road of the King |
User | vjudge3 |
Language | C++14 (GCC 5.4.1) |
Score | 1000 |
Code Size | 884 Byte |
Status | AC |
Exec Time | 111 ms |
Memory | 106752 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:22:25: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] 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 | 2 ms | 256 KB |
01-02.txt | AC | 1 ms | 256 KB |
01-03.txt | AC | 26 ms | 106752 KB |
01-04.txt | AC | 1 ms | 256 KB |
01-05.txt | AC | 26 ms | 106752 KB |
01-06.txt | AC | 42 ms | 106752 KB |
01-07.txt | AC | 109 ms | 106752 KB |
01-08.txt | AC | 111 ms | 106752 KB |
01-09.txt | AC | 111 ms | 106752 KB |
01-10.txt | AC | 111 ms | 106752 KB |
sample-01.txt | AC | 1 ms | 256 KB |
sample-02.txt | AC | 65 ms | 106752 KB |
sample-03.txt | AC | 33 ms | 53504 KB |