結果

問題 No.2378 Cards and Subsequences
ユーザー 👑 NachiaNachia
提出日時 2023-07-07 21:47:12
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 32 ms / 2,000 ms
コード長 1,081 bytes
コンパイル時間 964 ms
コンパイル使用メモリ 85,488 KB
実行使用メモリ 19,164 KB
最終ジャッジ日時 2023-09-28 22:50:28
合計ジャッジ時間 3,091 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 3 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 4 ms
4,836 KB
testcase_07 AC 5 ms
5,316 KB
testcase_08 AC 5 ms
5,756 KB
testcase_09 AC 7 ms
6,316 KB
testcase_10 AC 3 ms
4,376 KB
testcase_11 AC 25 ms
19,164 KB
testcase_12 AC 25 ms
18,908 KB
testcase_13 AC 26 ms
18,820 KB
testcase_14 AC 25 ms
18,844 KB
testcase_15 AC 26 ms
19,036 KB
testcase_16 AC 26 ms
18,820 KB
testcase_17 AC 26 ms
18,844 KB
testcase_18 AC 26 ms
18,980 KB
testcase_19 AC 25 ms
18,844 KB
testcase_20 AC 26 ms
18,884 KB
testcase_21 AC 25 ms
19,164 KB
testcase_22 AC 25 ms
18,828 KB
testcase_23 AC 25 ms
18,916 KB
testcase_24 AC 25 ms
18,844 KB
testcase_25 AC 25 ms
18,876 KB
testcase_26 AC 32 ms
18,836 KB
testcase_27 AC 32 ms
18,796 KB
testcase_28 AC 31 ms
18,796 KB
testcase_29 AC 32 ms
19,008 KB
testcase_30 AC 32 ms
18,972 KB
testcase_31 AC 32 ms
18,880 KB
testcase_32 AC 19 ms
18,824 KB
testcase_33 AC 25 ms
18,980 KB
testcase_34 AC 25 ms
18,796 KB
testcase_35 AC 25 ms
18,796 KB
testcase_36 AC 25 ms
18,832 KB
testcase_37 AC 6 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <atcoder/modint>
using namespace std;
using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
const i64 INF = 1001001001001001001;

using Modint = atcoder::static_modint<998244353>;

int main(){
    int N, M, K; cin >> N >> M >> K;
    vector<int> S(N);
    vector<int> A(M), B(M);
    rep(i,N){ cin >> S[i]; S[i]--; }
    rep(i,M) cin >> A[i];
    rep(i,M) cin >> B[i];
    vector<vector<Modint>> dp(2, vector<Modint>(K+1));
    dp[1][0] = 1;
    auto x = Modint(2).inv();
    rep(i,N){
        int j = i-1;
        while(j >= 0 && S[j] != S[i]) j--;
        int a = A[S[i]];
        int b = B[S[i]];
        vector<Modint> tmp = dp.back();
        for(int q=a; q<=K; q++) tmp[q] += (dp[i+1][q-a] - dp[j+1][q-a]);
        for(int q=b; q<=K; q++) tmp[q] += (dp[i+1][q-b] - dp[j+1][q-b]);
        dp.push_back(move(tmp));
    }
    Modint ans = dp.back()[K];
    cout << ans.val() << endl;
    return 0;
}
0