結果

問題 No.314 ケンケンパ
ユーザー syunsukesyunsuke
提出日時 2019-04-23 00:00:48
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 448 bytes
コンパイル時間 660 ms
コンパイル使用メモリ 64,456 KB
実行使用メモリ 11,264 KB
最終ジャッジ日時 2024-04-20 09:28:37
合計ジャッジ時間 1,408 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 7 ms
11,264 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 2 ms
5,376 KB
testcase_16 AC 3 ms
5,376 KB
testcase_17 AC 3 ms
5,376 KB
testcase_18 AC 5 ms
7,296 KB
testcase_19 AC 8 ms
11,224 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:10:21: warning: iteration 2 invokes undefined behavior [-Waggressive-loop-optimizations]
   10 |             dp[i][j]=0;
      |             ~~~~~~~~^~
main.cpp:9:22: note: within this loop
    9 |         for(int j=0;j<=2;j++){
      |                     ~^~~

ソースコード

diff #

#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int dp[1000005][2];
    int N;
    cin>>N;
    for(int i=0;i<=N;i++){
        for(int j=0;j<=2;j++){
            dp[i][j]=0;
        }
    }
    dp[1][0]=1;
    for(int i=2;i<=N;i++){
        dp[i][0]=dp[i-1][2];
        dp[i][1]=dp[i-1][0];
        dp[i][2]=(dp[i-1][0]+dp[i-1][1])%(1000000007);
    }
    cout<<(dp[N][0]+dp[N][1]+dp[N][2])%(1000000007)<<endl;
}
0