結果

問題 No.314 ケンケンパ
ユーザー izryt(趣味)izryt(趣味)
提出日時 2016-12-11 08:37:18
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 38 ms / 1,000 ms
コード長 2,287 bytes
コンパイル時間 947 ms
コンパイル使用メモリ 84,200 KB
実行使用メモリ 18,968 KB
最終ジャッジ日時 2023-08-19 10:41:48
合計ジャッジ時間 2,160 ms
ジャッジサーバーID
(参考情報)
judge15 / judge10
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
18,684 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,384 KB
testcase_04 AC 1 ms
4,384 KB
testcase_05 AC 1 ms
4,384 KB
testcase_06 AC 2 ms
4,384 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 1 ms
4,384 KB
testcase_11 AC 1 ms
4,384 KB
testcase_12 AC 2 ms
4,384 KB
testcase_13 AC 2 ms
4,384 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 2 ms
4,384 KB
testcase_16 AC 3 ms
4,384 KB
testcase_17 AC 6 ms
4,992 KB
testcase_18 AC 19 ms
10,796 KB
testcase_19 AC 38 ms
18,968 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>

using namespace std;

#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define omajinai ios::sync_with_stdio(false);cin.tie(0)
#define rep(i,x) for(int i=0;i<(int)(x);++i)
#define rep1(i,x) for(int i=1;i<=(int)(x);++i)
#define rrep(i,x) for(int i=(int)x-1;i>=0;--i)
#define rrep1(i,x) for(int i=(int)x;i>=1;--i)

using ll=long long;
using ld=long double;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int, int>;
using vpii=vector<pii>;

template<class T,class U>ostream&operator<<(ostream&os,const pair<T,U>p){os<<"("<<p.fst<<", "<<p.scd<<")";return os;}
template<class T>ostream&operator<<(ostream&os,const vector<T>v){rep(i,v.size()){if(i)os<<", ";os<<v[i];}return os;}
template<typename T>T&max(T&a,T&b){if(a>=b)return a;return b;}
template<typename T>T&min(T&a,T&b){if(a < b)return a;return b;}
template<typename T>bool chmax(T&a,T b){if(a < b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a > b){a=b;return true;}return false;}

constexpr int inf = 1e9;
constexpr ll linf = 3e18;
constexpr double eps = 1e-9;

const int mod = 1e9 + 7;
int dp[1000005][2][2]; // dp[何日目][今日][昨日]

signed main()
{
    int N; cin >> N;

    dp[0][0][1] = 1;

    for (int i = 0; i < N - 1; ++i) {
        for (int j = 0; j < 2; ++j) {
            for (int k = 0; k < 2; ++k) {
                for (int l = 0; l < 2; ++l) {
                    if (j == 1 && k == 1) continue;
                    if (k == 1 && l == 1) continue;
                    if (j == 0 && j == k && k == l) continue;
                    dp[i + 1][j][k] += dp[i][k][l];
                    dp[i + 1][j][k] %= mod;
                }
            }
        }
    }

    int sum = 0;

    rep(i, 2) {
        rep(j, 2) {
            if (i == 1 && j == 1) continue;
            sum += dp[N - 1][i][j];
            sum %= mod;
        }
    }

    cout << sum << endl;
}
0