結果

問題 No.2792 Security Cameras on Young Diagram
ユーザー けーけーけーけー
提出日時 2024-06-21 22:57:40
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 65 ms / 2,000 ms
コード長 658 bytes
コンパイル時間 2,121 ms
コンパイル使用メモリ 206,048 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-06-24 18:46:09
合計ジャッジ時間 3,333 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
5,248 KB
testcase_01 AC 4 ms
5,248 KB
testcase_02 AC 4 ms
5,376 KB
testcase_03 AC 4 ms
5,376 KB
testcase_04 AC 4 ms
5,376 KB
testcase_05 AC 3 ms
5,376 KB
testcase_06 AC 4 ms
5,376 KB
testcase_07 AC 4 ms
5,376 KB
testcase_08 AC 4 ms
5,376 KB
testcase_09 AC 3 ms
5,376 KB
testcase_10 AC 4 ms
5,376 KB
testcase_11 AC 4 ms
5,376 KB
testcase_12 AC 36 ms
5,376 KB
testcase_13 AC 22 ms
5,376 KB
testcase_14 AC 34 ms
5,376 KB
testcase_15 AC 14 ms
5,376 KB
testcase_16 AC 38 ms
5,376 KB
testcase_17 AC 50 ms
5,376 KB
testcase_18 AC 10 ms
5,376 KB
testcase_19 AC 9 ms
5,376 KB
testcase_20 AC 19 ms
5,376 KB
testcase_21 AC 3 ms
5,376 KB
testcase_22 AC 3 ms
5,376 KB
testcase_23 AC 65 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
using ll = long long;

#include <atcoder/modint>
using mint = atcoder::modint998244353;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];

    vector<mint> p(101010,1);
    rep(i,101010-1) p[i+1] *= p[i]*(i+1);

    mint ans = 1;

    rep(i,n){
        if(a[i]==1){
            ans += 1;
            continue;
        }
        int m = i+a[i]+1;
        int k = i+2;
        ans += p[m]/p[m-k]/p[k];
        ans -= p[m-1]/p[m-1-k]/p[k];
    }
    cout << ans.val() << endl;

}
0