結果

問題 No.533 Mysterious Stairs
ユーザー kakira9618kakira9618
提出日時 2018-06-16 02:04:26
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 48 ms / 5,000 ms
コード長 851 bytes
コンパイル時間 1,115 ms
コンパイル使用メモリ 147,964 KB
実行使用メモリ 22,628 KB
最終ジャッジ日時 2023-09-13 05:43:06
合計ジャッジ時間 2,521 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 1 ms
4,376 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 7 ms
5,144 KB
testcase_21 AC 7 ms
5,472 KB
testcase_22 AC 21 ms
10,380 KB
testcase_23 AC 47 ms
22,332 KB
testcase_24 AC 48 ms
22,628 KB
testcase_25 AC 8 ms
5,212 KB
testcase_26 AC 43 ms
19,736 KB
testcase_27 AC 14 ms
8,060 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"

using namespace std;

#define pb push_back
#define mp make_pair
constexpr int INF = 1 << 29;
constexpr int MOD = 1000000007;
typedef long long ll;
typedef unsigned long long ull;

constexpr int dx[4] = {1, 0, -1, 0};
constexpr int dy[4] = {0, 1, 0, -1};

int main() {
    int N;
    cin >> N;
    vector<vector<int>> dp(4, vector<int>(N + 1));
    dp[0][0] = 1;

    for (int j = 1; j <= N; j++) {
        for (int k = 1; k < 4; k++) {
            for(int i = 0; i < 4; i++) {
                if (i == k) continue;
                if (j - k >= 0) {
                    dp[k][j] += dp[i][j - k];
                    dp[k][j] %= MOD;
                }
            }
        }
    }
    int sum = 0;
    for (int i = 0; i < 4; i++) {
        sum += dp[i][N];
        sum %= MOD;
    }
    cout << sum << endl;


    return 0;
}
0