結果

問題 No.314 ケンケンパ
ユーザー ugis_progugis_prog
提出日時 2018-10-24 16:38:30
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 33 ms / 1,000 ms
コード長 725 bytes
コンパイル時間 539 ms
コンパイル使用メモリ 60,616 KB
実行使用メモリ 26,784 KB
最終ジャッジ日時 2023-08-12 06:53:19
合計ジャッジ時間 1,829 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 33 ms
26,424 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 5 ms
5,680 KB
testcase_18 AC 17 ms
14,536 KB
testcase_19 AC 32 ms
26,784 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:26:29: warning: iteration 3 invokes undefined behavior [-Waggressive-loop-optimizations]
     rep(i,4) (ans += dp[N][i]) %= MOD;
                      ~~~~~~~^
main.cpp:8:34: note: within this loop
 #define rep(i,N) for(int(i)=0;(i)<(N);++(i))
                               ~~~^~~~
main.cpp:26:5: note: in expansion of macro ‘rep’
     rep(i,4) (ans += dp[N][i]) %= MOD;
     ^~~

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long;
const int MOD = 1e9+7;
#define put(n) cout<<(n)<<endl
#define rep(i,N) for(int(i)=0;(i)<(N);++(i))
#define rrep(i,N) for(int (i)=(N-1);(i)>=(0);--(i))
#define all(v) (v).begin() , (v).end()
#define rall(v) (v).rbegin() , (v).rend()
#define pb(n) push_back(n)

int a[1010],b[1010];//,dp[1010][1010];
ll dp[1001000][3];

int main(){
    int N; cin >> N;
    dp[1][1] = 1;
    for(int i=1;i<=N;++i){
        (dp[i][2] += dp[i-1][1]) %= MOD;
        (dp[i][1] += dp[i-1][0]) %= MOD;
        (dp[i][0] += dp[i-1][2] + dp[i-1][1]) %= MOD;
    }
    ll ans = 0;
    rep(i,4) (ans += dp[N][i]) %= MOD;
    cout << ans << endl;  
}
0