結果
問題 | No.314 ケンケンパ |
ユーザー | koyumeishi |
提出日時 | 2015-12-07 00:08:14 |
言語 | C++11 (gcc 11.4.0) |
結果 |
CE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 802 bytes |
コンパイル時間 | 409 ms |
コンパイル使用メモリ | 68,820 KB |
最終ジャッジ日時 | 2023-10-12 18:08:43 |
合計ジャッジ時間 | 784 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge14 |
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:37:18: error: ‘accumulate’ was not declared in this scope 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; }