結果

問題 No.314 ケンケンパ
ユーザー zoom4638zoom4638
提出日時 2015-12-11 17:31:44
言語 C++11
(gcc 11.4.0)
結果
RE  
実行時間 -
コード長 778 bytes
コンパイル時間 371 ms
コンパイル使用メモリ 52,516 KB
実行使用メモリ 7,096 KB
最終ジャッジ日時 2023-10-13 10:56:48
合計ジャッジ時間 2,306 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 WA -
testcase_05 AC 1 ms
4,352 KB
testcase_06 AC 1 ms
4,348 KB
testcase_07 AC 2 ms
4,352 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 ms
4,352 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 1 ms
4,348 KB
testcase_13 AC 2 ms
4,352 KB
testcase_14 AC 2 ms
4,352 KB
testcase_15 AC 2 ms
4,352 KB
testcase_16 AC 4 ms
4,352 KB
testcase_17 AC 8 ms
7,096 KB
testcase_18 RE -
testcase_19 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
using namespace std;

int dp[100003][3][3];

int main() {
	int n;
	cin >> n;
	dp[1][1][0] = 1;
	
	for (int i = 2; i <= n; i++){
		for (int j = 0; j < 3; j++){
			for (int k = 0; k < 3; k++){
				if (dp[i - 1][j][k] != 0){
					if (j == 1 && k == 1){
						dp[i][2][j] += dp[i - 1][j][k];
						dp[i][2][j] %= 1000000007;
					}else{
						if (j == 2){
							dp[i][1][j] += dp[i - 1][j][k];
							dp[i][1][j] %= 1000000007;
						}else{
							for (int l = 1; l < 3; l++){
								dp[i][l][j] += dp[i - 1][j][k];
								dp[i][l][j] %= 1000000007;
							}
						}
					}
				}
			}
		}
	}
	
	int ans = 0;
	
	for (int i = 1; i < 3; i++){
		for (int j = 1; j < 3; j++){
			ans += dp[n][i][j];
			ans %= 1000000007;
		}
	}
	
	cout << ans << endl;
	return 0;
}
0