結果

問題 No.314 ケンケンパ
ユーザー oxyshoweroxyshower
提出日時 2020-01-09 14:13:41
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 89 ms / 1,000 ms
コード長 1,026 bytes
コンパイル時間 1,716 ms
コンパイル使用メモリ 169,744 KB
実行使用メモリ 58,088 KB
最終ジャッジ日時 2023-08-15 01:16:31
合計ジャッジ時間 3,257 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 86 ms
56,720 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,384 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,384 KB
testcase_07 AC 2 ms
4,384 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 1 ms
4,384 KB
testcase_12 AC 1 ms
4,384 KB
testcase_13 AC 2 ms
4,384 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 4 ms
4,400 KB
testcase_17 AC 11 ms
8,500 KB
testcase_18 AC 44 ms
29,128 KB
testcase_19 AC 89 ms
58,088 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long
const int MOD = 1e9 + 7;
template<class T> vector<T> make_vec(size_t a) { return vector<T>(a); }
template<class T, class... Ts> auto make_vec(size_t a, Ts... ts) {
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template<class T, class V>
typename enable_if<is_class<T>::value == 0>::type fill(T &t, const V &v) {
    t = v;
}
template<class T, class V>
typename enable_if<is_class<T>::value != 0>::type fill(T &t, const V &v){
    for (auto &e : t) fill(e, v);
}
// auto v = make_vec<int>(h, w);
// fill(v, 0);

signed main(){

  int n; cin >> n;
  auto dp = make_vec<int>(n, 3);
  fill(dp, 0);
  dp[0][1] = 1;
  for(int i = 1; i < n; i++){
    dp[i][0] = dp[i-1][1] + dp[i-1][2];
    dp[i][1] = dp[i-1][0];
    dp[i][2] = dp[i-1][1];
    for(int j = 0; j < 3; j++){
      dp[i][j] %= MOD;
    }
  }
  cout << (dp[n-1][0] + dp[n-1][1] + dp[n-1][2]) % MOD << endl;

  return 0;
}
0