Submission #5892715
Source Code Expand
#include <bits/stdc++.h> using namespace std; const int maxn = 333, mod = 1'000'000'007; int mul(long long a, long long b){ return a * b % mod; } int f[maxn][maxn][maxn], n, m; int solve(int day, int group, int on_one){ if(group > n) return 0; if(day == m) return on_one == n; int & v = f[day][group][on_one]; if(~v) return v; v = 0; v += mul(solve(day + 1, group + 1, on_one), n - group); v += mul(solve(day + 1, group, on_one), group - on_one); if(v >= mod) v -= mod; v += mul(solve(day + 1, group, group), on_one); if(v >= mod) v -= mod; return v; } int main(){ cin >> n >> m; memset(f, -1, sizeof(f)); cout << solve(0, 1, 1) << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | F - Road of the King |
User | FMota |
Language | C++14 (GCC 5.4.1) |
Score | 1000 |
Code Size | 688 Byte |
Status | AC |
Exec Time | 205 ms |
Memory | 144512 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 | 37 ms | 144512 KB |
01-02.txt | AC | 37 ms | 144512 KB |
01-03.txt | AC | 37 ms | 144512 KB |
01-04.txt | AC | 37 ms | 144512 KB |
01-05.txt | AC | 38 ms | 144512 KB |
01-06.txt | AC | 81 ms | 144512 KB |
01-07.txt | AC | 205 ms | 144512 KB |
01-08.txt | AC | 203 ms | 144512 KB |
01-09.txt | AC | 204 ms | 144512 KB |
01-10.txt | AC | 201 ms | 144512 KB |
sample-01.txt | AC | 37 ms | 144512 KB |
sample-02.txt | AC | 136 ms | 144512 KB |
sample-03.txt | AC | 56 ms | 144512 KB |