結果
| 問題 |
No.314 ケンケンパ
|
| コンテスト | |
| ユーザー |
koyumeishi
|
| 提出日時 | 2015-12-07 00:08:14 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 802 bytes |
| コンパイル時間 | 550 ms |
| コンパイル使用メモリ | 70,760 KB |
| 最終ジャッジ日時 | 2024-11-14 19:30:12 |
| 合計ジャッジ時間 | 876 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:37:25: error: ‘accumulate’ was not declared in this scope
37 | long long ans = accumulate(dp[0].begin(), dp[0].end(), 0LL) + accumulate(dp[1].begin(), dp[1].end(), 0LL);
| ^~~~~~~~~~
ソースコード
#include <iostream>
#include <vector>
#include <cstdio>
#include <sstream>
#include <map>
#include <string>
#include <algorithm>
#include <queue>
#include <cmath>
#include <set>
using namespace std;
#define MOD 1000000007
int main(){
int n;
cin >> n;
vector<vector<long long>> dp(2, vector<long long>(2, 0));
dp[1][0] = 1;
for(int i=1; i<n; i++){
vector<vector<long long>> dp_(2, vector<long long>(2, 0));
for(int a=0; a<2; a++){
for(int b=0; b<2; b++){
if(a!=0 || b!=0){
dp_[b][0] += dp[a][b];
dp_[b][0] %= MOD;
}
if(b==0){
dp_[b][1] += dp[a][b];
dp_[b][1] %= MOD;
}
}
}
swap(dp, dp_);
}
long long ans = accumulate(dp[0].begin(), dp[0].end(), 0LL) + accumulate(dp[1].begin(), dp[1].end(), 0LL);
ans %=MOD;
cout << ans << endl;
return 0;
}
koyumeishi