結果

問題 No.314 ケンケンパ
ユーザー mmn15277198mmn15277198
提出日時 2021-02-01 11:22:29
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 880 bytes
コンパイル時間 584 ms
コンパイル使用メモリ 73,484 KB
実行使用メモリ 58,056 KB
最終ジャッジ日時 2023-09-12 10:07:30
合計ジャッジ時間 2,068 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long ll;

const int mod = 1e9 + 7;

int main(void){
    int n;
    cin >> n;
    vector<vector<int>> dp(n + 10 , vector<int>(2 , 0));
    dp[2][0] = 1;
    dp[3][1] = 1;
    for(int i = 2; i < n + 5; i++){
        dp[i + 2][0] = dp[i][0]; //  xoxoxoの繰り返し
        dp[i + 3][1] = dp[i][1]; //  xxoxxoxxoの繰り返し
        dp[i + 2][0] += dp[i][1]; // xxo -> xo への遷移
        dp[i + 3][1] += dp[i][0]; // xo -> xxo への遷移
        dp[i + 2][0] %= mod; 
        dp[i + 3][1] %= mod;
    }
    
    // 丁度nで終わった回数と,n + 1で終わった回数
    cout << (dp[n][0] + dp[n][1] + dp[n + 1][0] + dp[n + 1][1]) % mod << endl;
    // n + 2 で終わった場合は、n - 1 -> xxo n - 1 -> xxo が同じなのでカウントしない

    return 0;
}
0