結果

問題 No.533 Mysterious Stairs
ユーザー Manuel1024Manuel1024
提出日時 2021-03-05 02:38:49
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 96 ms / 5,000 ms
コード長 591 bytes
コンパイル時間 726 ms
コンパイル使用メモリ 72,688 KB
実行使用メモリ 57,868 KB
最終ジャッジ日時 2024-04-15 17:07:26
合計ジャッジ時間 2,181 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 2 ms
6,944 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 2 ms
6,944 KB
testcase_08 AC 2 ms
6,944 KB
testcase_09 AC 2 ms
6,940 KB
testcase_10 AC 2 ms
6,944 KB
testcase_11 AC 2 ms
6,940 KB
testcase_12 AC 2 ms
6,944 KB
testcase_13 AC 2 ms
6,940 KB
testcase_14 AC 2 ms
6,940 KB
testcase_15 AC 2 ms
6,940 KB
testcase_16 AC 2 ms
6,944 KB
testcase_17 AC 2 ms
6,940 KB
testcase_18 AC 3 ms
6,940 KB
testcase_19 AC 3 ms
6,940 KB
testcase_20 AC 13 ms
9,472 KB
testcase_21 AC 15 ms
9,984 KB
testcase_22 AC 38 ms
24,120 KB
testcase_23 AC 95 ms
57,356 KB
testcase_24 AC 96 ms
57,868 KB
testcase_25 AC 13 ms
9,344 KB
testcase_26 AC 83 ms
50,492 KB
testcase_27 AC 26 ms
16,900 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
using namespace std;
using ll = long long int;
constexpr ll MOD = 1'000'000'007;

int main(){
    int n;
    cin >> n;
    vector<vector<ll>> memo(n+1, vector<ll>(3, 0));
    memo[0][0] = memo[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(i-j-1 < 0 || j == k) continue;
                memo[i][j] += memo[i-j-1][k];
                memo[i][j] %= MOD;
            }
        }
    }
    cout << (memo[n][0] + memo[n][1] + memo[n][2])%MOD << endl;
    return 0;
}
0