結果

問題 No.314 ケンケンパ
ユーザー cielciel
提出日時 2015-12-07 00:26:35
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 705 ms / 1,000 ms
コード長 355 bytes
コンパイル時間 410 ms
コンパイル使用メモリ 59,928 KB
実行使用メモリ 210,804 KB
最終ジャッジ日時 2023-10-12 18:39:05
合計ジャッジ時間 3,713 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 696 ms
209,996 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 1 ms
4,352 KB
testcase_03 AC 2 ms
4,352 KB
testcase_04 AC 1 ms
4,352 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,352 KB
testcase_07 AC 2 ms
4,352 KB
testcase_08 AC 1 ms
4,348 KB
testcase_09 AC 1 ms
4,348 KB
testcase_10 AC 2 ms
4,352 KB
testcase_11 AC 2 ms
4,352 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 2 ms
4,348 KB
testcase_14 AC 5 ms
4,348 KB
testcase_15 AC 7 ms
4,384 KB
testcase_16 AC 15 ms
6,976 KB
testcase_17 AC 56 ms
19,524 KB
testcase_18 AC 276 ms
81,180 KB
testcase_19 AC 705 ms
210,804 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <unordered_map>
#include <cstdio>
using namespace std;

unordered_map<int,int>memo;
int dfs(int k,int p,int d){
	if(k<0||p<0)return 0;
	if(d==0)return 1;
	auto x=d*8+k*2+p;
	if(memo.find(x)==memo.end()){
		memo[x]=(dfs(k-1,1,d-1)+dfs(2,p-1,d-1))%1000000007;
	}
	return memo[x];
}
int main(){
	int n;
	scanf("%d",&n);
	printf("%d\n",dfs(2,0,n));
}
0