結果

問題 No.1331 Moving Penguin
ユーザー SSRSSSRS
提出日時 2021-01-08 22:08:25
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 855 bytes
コンパイル時間 2,331 ms
コンパイル使用メモリ 195,288 KB
実行使用メモリ 448,396 KB
最終ジャッジ日時 2024-04-28 03:17:56
合計ジャッジ時間 17,762 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 8 ms
6,820 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 28 ms
14,492 KB
testcase_05 AC 1,322 ms
404,224 KB
testcase_06 AC 1,336 ms
404,280 KB
testcase_07 AC 1,316 ms
404,156 KB
testcase_08 AC 41 ms
27,024 KB
testcase_09 AC 38 ms
26,964 KB
testcase_10 AC 39 ms
27,108 KB
testcase_11 AC 51 ms
30,180 KB
testcase_12 AC 48 ms
30,164 KB
testcase_13 AC 47 ms
30,064 KB
testcase_14 AC 109 ms
51,996 KB
testcase_15 AC 122 ms
52,000 KB
testcase_16 AC 123 ms
52,056 KB
testcase_17 AC 40 ms
26,276 KB
testcase_18 AC 37 ms
25,976 KB
testcase_19 AC 35 ms
24,984 KB
testcase_20 AC 36 ms
25,292 KB
testcase_21 AC 36 ms
26,060 KB
testcase_22 AC 40 ms
26,140 KB
testcase_23 AC 63 ms
36,392 KB
testcase_24 AC 66 ms
36,456 KB
testcase_25 AC 65 ms
36,276 KB
testcase_26 AC 124 ms
36,384 KB
testcase_27 AC 122 ms
36,060 KB
testcase_28 AC 135 ms
38,668 KB
testcase_29 AC 15 ms
9,824 KB
testcase_30 AC 29 ms
13,440 KB
testcase_31 AC 60 ms
23,400 KB
testcase_32 AC 27 ms
11,520 KB
testcase_33 AC 43 ms
17,280 KB
testcase_34 AC 70 ms
24,352 KB
testcase_35 TLE -
testcase_36 TLE -
testcase_37 TLE -
testcase_38 AC 30 ms
13,312 KB
testcase_39 AC 118 ms
35,584 KB
testcase_40 AC 50 ms
20,352 KB
testcase_41 TLE -
testcase_42 AC 260 ms
93,560 KB
testcase_43 AC 226 ms
93,496 KB
testcase_44 AC 227 ms
93,652 KB
testcase_45 AC 77 ms
39,128 KB
testcase_46 AC 73 ms
39,180 KB
testcase_47 AC 72 ms
39,100 KB
testcase_48 AC 30 ms
23,916 KB
権限があれば一括ダウンロードができます

ソースコード

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<unordered_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 - 1 < N){
        next[i + P.first - 1][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] + 1] += dp[i];
    }
  }
  cout << dp[N - 1] << endl;
}
0