結果
| 問題 | No.314 ケンケンパ |
| コンテスト | |
| ユーザー |
syunsuke
|
| 提出日時 | 2019-04-23 00:00:48 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 448 bytes |
| 記録 | |
| コンパイル時間 | 779 ms |
| コンパイル使用メモリ | 63,868 KB |
| 実行使用メモリ | 11,256 KB |
| 最終ジャッジ日時 | 2024-10-12 04:53:50 |
| 合計ジャッジ時間 | 1,508 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 15 WA * 2 |
コンパイルメッセージ
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++){
| ~^~~
ソースコード
#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;
}
syunsuke