結果

問題 No.1331 Moving Penguin
ユーザー SSRSSSRS
提出日時 2021-01-08 22:40:10
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 874 bytes
コンパイル時間 2,686 ms
コンパイル使用メモリ 192,356 KB
実行使用メモリ 15,328 KB
最終ジャッジ日時 2024-04-28 04:08:37
合計ジャッジ時間 15,350 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 6 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 45 ms
15,328 KB
testcase_05 AC 1,056 ms
9,380 KB
testcase_06 AC 1,068 ms
9,316 KB
testcase_07 AC 1,068 ms
9,344 KB
testcase_08 AC 22 ms
9,000 KB
testcase_09 AC 22 ms
8,936 KB
testcase_10 AC 22 ms
9,088 KB
testcase_11 AC 26 ms
8,944 KB
testcase_12 AC 26 ms
9,088 KB
testcase_13 AC 28 ms
9,088 KB
testcase_14 AC 60 ms
9,004 KB
testcase_15 AC 60 ms
9,088 KB
testcase_16 AC 59 ms
8,960 KB
testcase_17 AC 20 ms
9,088 KB
testcase_18 AC 20 ms
9,088 KB
testcase_19 AC 18 ms
8,936 KB
testcase_20 AC 19 ms
9,068 KB
testcase_21 AC 20 ms
9,088 KB
testcase_22 AC 20 ms
9,088 KB
testcase_23 AC 35 ms
9,044 KB
testcase_24 AC 35 ms
8,960 KB
testcase_25 AC 35 ms
8,960 KB
testcase_26 AC 85 ms
11,648 KB
testcase_27 AC 82 ms
11,648 KB
testcase_28 AC 90 ms
11,628 KB
testcase_29 AC 16 ms
9,088 KB
testcase_30 AC 22 ms
5,888 KB
testcase_31 AC 41 ms
8,044 KB
testcase_32 AC 18 ms
5,632 KB
testcase_33 AC 30 ms
7,040 KB
testcase_34 AC 47 ms
8,796 KB
testcase_35 TLE -
testcase_36 TLE -
testcase_37 TLE -
testcase_38 AC 22 ms
6,016 KB
testcase_39 AC 81 ms
11,520 KB
testcase_40 AC 38 ms
7,424 KB
testcase_41 AC 1,344 ms
12,288 KB
testcase_42 AC 131 ms
9,472 KB
testcase_43 AC 134 ms
9,472 KB
testcase_44 AC 134 ms
9,472 KB
testcase_45 AC 41 ms
9,216 KB
testcase_46 AC 41 ms
9,216 KB
testcase_47 AC 40 ms
9,216 KB
testcase_48 AC 17 ms
9,088 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC target("avx")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("O3")
#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]){
      P.second %= MOD;
      dp[i] += P.second;
      if (i + P.first < N){
        next[i + P.first][P.first] += P.second;
      }
    }
    dp[i] %= MOD;
    next[i].clear();
    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] << "\n";
}
0