結果

問題 No.2556 Increasing Matrix
ユーザー hotman78hotman78
提出日時 2023-10-05 16:55:37
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 987 bytes
コンパイル時間 7,241 ms
コンパイル使用メモリ 311,236 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2023-12-01 23:31:06
合計ジャッジ時間 8,325 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 2 ms
6,676 KB
testcase_04 AC 2 ms
6,676 KB
testcase_05 AC 2 ms
6,676 KB
testcase_06 AC 2 ms
6,676 KB
testcase_07 AC 2 ms
6,676 KB
testcase_08 AC 2 ms
6,676 KB
testcase_09 AC 6 ms
6,676 KB
testcase_10 AC 2 ms
6,676 KB
testcase_11 AC 3 ms
6,676 KB
testcase_12 AC 3 ms
6,676 KB
testcase_13 AC 19 ms
6,676 KB
testcase_14 AC 76 ms
6,676 KB
testcase_15 AC 60 ms
6,676 KB
testcase_16 AC 42 ms
6,676 KB
testcase_17 AC 100 ms
6,676 KB
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "testlib.h"
#include <atcoder/modint.hpp>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define lint long long
using mint = modint998244353;

mint solve(vector<lint> p) {
    lint n = p.size();
    mint ans = 1;
    rep(i, n) for (lint j = i + 1; j < n; ++j) { ans *= p[j] - p[i] + (j - i); }
    mint fact = 1;
    for (int i = 1; i < n; ++i) {
        fact *= i;
        ans /= fact;
    }
    return ans;
}

int main(int argc, char *argv[]) {
    registerValidation(argc, argv);
    int n = inf.readInt(1, 5000, "n");
    vector<lint> p(n);
    inf.readEoln();
    rep(i, n) {
        if (i) {
            inf.readSpace();
        }
        p[i] = inf.readInt(1, 1'000'000'000, "p_i");
    }
    inf.readEoln();
    inf.readEof();
    rep(i, n - 1) { assert(p[i] <= p[i + 1]); }
    vector<lint> q(n);
    rep(i, n) q[n - 1 - i] = p.back() - p[i] + 1;
    cout << (solve(p) * solve(q)).val() << endl;
}
0