結果

問題 No.533 Mysterious Stairs
コンテスト
ユーザー Rumain831
提出日時 2026-10-23 18:51:05
言語 C++23(gcc16)
(gcc 16.2.0 + boost 1.92.0 + ACL)
コンパイル:
g++-16 -O2 -fplugin=/usr/lib/yukicoder/noavx512-gcc16.so -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 61 ms / 5,000 ms
+ 733µs
コード長 516 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,996 ms
コンパイル使用メモリ 179,580 KB
実行使用メモリ 57,884 KB
最終ジャッジ日時 2026-10-23 18:51:11
合計ジャッジ時間 5,316 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
using ll = long long;

int main(void){
  int n; cin >> n;
  vector dp(n+3, vector<ll>(3));
  ll mod=1e9+7;
  for(int i=1; i<=3; i++) dp[i][i-1]=1;
  for(int i=1; i<=n; i++){
    for(int p=0; p<3; p++)for(int q=0; q<3; q++)if(p!=q){
      int ni=i+q+1;
      if(ni<=n){
        dp[ni][q]+=dp[i][p];
        dp[ni][q]%=mod;
      }
    }
  }
  ll ans=0;
  for(int i=0; i<3; i++) ans+=dp[n][i], ans%=mod;
  cout << ans << endl;
  return 0; 
}
0