結果

問題 No.1331 Moving Penguin
ユーザー SSRSSSRS
提出日時 2021-01-08 22:33:44
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 833 bytes
コンパイル時間 2,679 ms
コンパイル使用メモリ 194,740 KB
実行使用メモリ 646,392 KB
最終ジャッジ日時 2024-04-28 04:00:07
合計ジャッジ時間 14,403 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 8 ms
13,756 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 45 ms
15,304 KB
testcase_05 TLE -
testcase_06 TLE -
testcase_07 TLE -
testcase_08 AC 34 ms
21,592 KB
testcase_09 AC 33 ms
21,588 KB
testcase_10 AC 39 ms
21,632 KB
testcase_11 AC 45 ms
27,792 KB
testcase_12 AC 43 ms
27,752 KB
testcase_13 AC 44 ms
27,844 KB
testcase_14 AC 122 ms
71,576 KB
testcase_15 AC 123 ms
71,404 KB
testcase_16 AC 125 ms
71,596 KB
testcase_17 AC 31 ms
20,008 KB
testcase_18 AC 30 ms
19,620 KB
testcase_19 AC 27 ms
17,472 KB
testcase_20 AC 27 ms
17,936 KB
testcase_21 AC 28 ms
19,556 KB
testcase_22 AC 28 ms
19,536 KB
testcase_23 AC 64 ms
40,336 KB
testcase_24 AC 65 ms
40,352 KB
testcase_25 AC 64 ms
40,352 KB
testcase_26 AC 171 ms
42,228 KB
testcase_27 AC 169 ms
41,696 KB
testcase_28 AC 178 ms
46,208 KB
testcase_29 AC 16 ms
9,048 KB
testcase_30 AC 40 ms
14,720 KB
testcase_31 AC 85 ms
26,896 KB
testcase_32 AC 35 ms
12,288 KB
testcase_33 AC 55 ms
19,200 KB
testcase_34 AC 97 ms
27,720 KB
testcase_35 MLE -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC target("avx2")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++){
    cin >> A[i];
  }
  vector<long long> dp(N, 0);
  dp[0] = 1;
  vector<map<int, long long>> next(N);
  for (int i = 0; i < N; i++){
    for (auto &P : next[i]){
      dp[i] += P.second;
      if (i + P.first < N){
        next[i + P.first][P.first] += P.second;
      }
    }
    dp[i] %= MOD;
    if (i < N - 1 && A[i] != 1){
      dp[i + 1] += dp[i];
      if (dp[i + 1] >= MOD){
        dp[i + 1] -= MOD;
      }
    }
    if (i + A[i] < N){
      next[i + A[i]][A[i]] += dp[i];
    }
  }
  cout << dp[N - 1] << endl;
}
0