CODE FESTIVAL 2016 Final

Submission #5892715

Source codeソースコード

#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

Task問題 F - Road of the King
User nameユーザ名 fmota
Created time投稿日時
Language言語 C++14 (GCC 5.4.1)
Status状態 AC
Score得点 1000
Source lengthソースコード長 688 Byte
File nameファイル名
Exec time実行時間 205 ms
Memory usageメモリ使用量 144512 KB

Test case

Set

Set name Score得点 / Max score Cases
sample - sample-01.txt,sample-02.txt,sample-03.txt
all 1000 / 1000 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

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
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