結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 661 ms
210,080 KB
testcase_01 AC 1 ms
4,352 KB
testcase_02 AC 1 ms
4,352 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 1 ms
4,348 KB
testcase_05 AC 1 ms
4,352 KB
testcase_06 AC 1 ms
4,348 KB
testcase_07 AC 1 ms
4,348 KB
testcase_08 AC 1 ms
4,352 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 2 ms
4,352 KB
testcase_11 AC 1 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 2 ms
4,348 KB
testcase_14 AC 4 ms
4,348 KB
testcase_15 AC 6 ms
4,444 KB
testcase_16 AC 14 ms
6,984 KB
testcase_17 AC 52 ms
19,444 KB
testcase_18 AC 264 ms
81,176 KB
testcase_19 AC 666 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<<3)|(k<<1)|p;
	if(memo.find(x)!=memo.end())return memo[x];
	return memo[x]=(dfs(k-1,1,d-1)+dfs(2,p-1,d-1))%1000000007;
}
int main(){
	int n;
	scanf("%d",&n);
	printf("%d\n",dfs(2,0,n));
}
0