結果

問題 No.2378 Cards and Subsequences
ユーザー 👑 hitonanodehitonanode
提出日時 2023-07-14 09:14:15
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 62 ms / 2,000 ms
コード長 909 bytes
コンパイル時間 989 ms
コンパイル使用メモリ 96,816 KB
実行使用メモリ 19,028 KB
最終ジャッジ日時 2023-10-13 22:02:02
合計ジャッジ時間 3,796 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,352 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 3 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 4 ms
4,348 KB
testcase_07 AC 8 ms
8,568 KB
testcase_08 AC 8 ms
7,332 KB
testcase_09 AC 8 ms
6,516 KB
testcase_10 AC 7 ms
8,012 KB
testcase_11 AC 36 ms
18,932 KB
testcase_12 AC 36 ms
18,804 KB
testcase_13 AC 35 ms
18,788 KB
testcase_14 AC 34 ms
18,788 KB
testcase_15 AC 35 ms
19,028 KB
testcase_16 AC 35 ms
19,024 KB
testcase_17 AC 35 ms
18,932 KB
testcase_18 AC 36 ms
18,860 KB
testcase_19 AC 35 ms
18,856 KB
testcase_20 AC 35 ms
18,880 KB
testcase_21 AC 36 ms
19,028 KB
testcase_22 AC 35 ms
18,932 KB
testcase_23 AC 35 ms
18,876 KB
testcase_24 AC 36 ms
18,784 KB
testcase_25 AC 35 ms
18,784 KB
testcase_26 AC 61 ms
18,840 KB
testcase_27 AC 61 ms
18,808 KB
testcase_28 AC 62 ms
18,780 KB
testcase_29 AC 61 ms
18,860 KB
testcase_30 AC 60 ms
18,784 KB
testcase_31 AC 54 ms
18,868 KB
testcase_32 AC 15 ms
18,880 KB
testcase_33 AC 37 ms
18,812 KB
testcase_34 AC 37 ms
18,880 KB
testcase_35 AC 37 ms
18,852 KB
testcase_36 AC 37 ms
18,932 KB
testcase_37 AC 5 ms
4,352 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
using namespace std;

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

int main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    int N, M, K;
    cin >> N >> M >> K;
    vector<int> S(N), A(M), B(M);
    for (auto &x : S) cin >> x, --x;
    for (auto &x : A) cin >> x;
    for (auto &x : B) cin >> x;
    for (int i = 0; i < M; ++i) {
        if (A.at(i) > B.at(i)) std::swap(A.at(i), B.at(i));
    }

    vector<mint> dpall(K + 1);
    dpall.at(0) = 1;
    vector dp(M, vector<mint>(K + 1));

    for (const int s : S) {
        const int a = A.at(s), b = B.at(s);

        for (int k = K - a; k >= 0; --k) {
            dpall.at(k + a) += dpall.at(k) + dp.at(s).at(k);
            if (k + b <= K) dpall.at(k + b) += dpall.at(k) + dp.at(s).at(k);
            dp.at(s).at(k) = -dpall.at(k);
        }
    }
    cout << dpall.back().val() << '\n';
}
0