CODE FESTIVAL 2016 Final (Parallel)

Submission #1352063

Source codeソースコード

#include<iostream>
#include<algorithm>
using namespace std;
long long n, m, dp[305][305][305], mod = 1000000007;
long long solve(long long pos, long long rec1, long long rec2) {
	if (rec1 + rec2 > n)return 0;
	if (pos == m) {
		if (rec1 == n && rec2 == 0)return 1;
		return 0;
	}
	if (dp[pos][rec1][rec2] >= 1)return dp[pos][rec1][rec2] - 1;
	long long ret = 0;
	ret += solve(pos + 1, rec1 + rec2, 0)*rec1;
	ret += solve(pos + 1, rec1, rec2)*rec2;
	ret += solve(pos + 1, rec1, rec2 + 1)*(n - rec1 - rec2); ret %= mod;
	dp[pos][rec1][rec2] = ret + 1;
	return ret;
}
int main() {
	cin >> n >> m;
	cout << solve(0, 1, 0) << endl;
	return 0;
}

Submission

Task問題 F - Road of the King
User nameユーザ名 E869120
Created time投稿日時
Language言語 C++14 (GCC 5.4.1)
Status状態 AC
Score得点 1000
Source lengthソースコード長 661 Byte
File nameファイル名
Exec time実行時間 196 ms
Memory usageメモリ使用量 217344 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 1 ms 256 KB
01-02.txt AC 1 ms 256 KB
01-03.txt AC 43 ms 217344 KB
01-04.txt AC 1 ms 256 KB
01-05.txt AC 43 ms 217344 KB
01-06.txt AC 75 ms 217344 KB
01-07.txt AC 193 ms 217344 KB
01-08.txt AC 195 ms 217344 KB
01-09.txt AC 196 ms 217344 KB
01-10.txt AC 195 ms 217344 KB
sample-01.txt AC 1 ms 256 KB
sample-02.txt AC 121 ms 217344 KB
sample-03.txt AC 41 ms 108800 KB