結果

問題 No.2215 Slide Subset Sum
ユーザー i_am_noobi_am_noob
提出日時 2023-02-12 02:10:59
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 236 ms / 3,000 ms
コード長 1,475 bytes
コンパイル時間 2,507 ms
コンパイル使用メモリ 199,688 KB
実行使用メモリ 168,476 KB
最終ジャッジ日時 2023-09-22 20:45:50
合計ジャッジ時間 12,314 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 130 ms
168,412 KB
testcase_01 AC 152 ms
168,228 KB
testcase_02 AC 223 ms
168,472 KB
testcase_03 AC 236 ms
168,192 KB
testcase_04 AC 210 ms
168,432 KB
testcase_05 AC 2 ms
5,552 KB
testcase_06 AC 2 ms
5,556 KB
testcase_07 AC 2 ms
5,504 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,536 KB
testcase_10 AC 2 ms
5,628 KB
testcase_11 AC 2 ms
5,488 KB
testcase_12 AC 2 ms
5,580 KB
testcase_13 AC 2 ms
5,628 KB
testcase_14 AC 2 ms
5,576 KB
testcase_15 AC 2 ms
5,404 KB
testcase_16 AC 2 ms
5,796 KB
testcase_17 AC 184 ms
168,232 KB
testcase_18 AC 185 ms
168,276 KB
testcase_19 AC 219 ms
168,340 KB
testcase_20 AC 177 ms
168,304 KB
testcase_21 AC 205 ms
168,212 KB
testcase_22 AC 173 ms
168,284 KB
testcase_23 AC 150 ms
168,252 KB
testcase_24 AC 151 ms
168,204 KB
testcase_25 AC 158 ms
168,336 KB
testcase_26 AC 176 ms
168,220 KB
testcase_27 AC 11 ms
15,920 KB
testcase_28 AC 14 ms
32,296 KB
testcase_29 AC 15 ms
19,828 KB
testcase_30 AC 102 ms
97,884 KB
testcase_31 AC 53 ms
65,844 KB
testcase_32 AC 20 ms
20,008 KB
testcase_33 AC 136 ms
128,644 KB
testcase_34 AC 108 ms
133,008 KB
testcase_35 AC 28 ms
52,716 KB
testcase_36 AC 30 ms
40,408 KB
testcase_37 AC 145 ms
168,280 KB
testcase_38 AC 71 ms
168,476 KB
testcase_39 AC 137 ms
168,192 KB
testcase_40 AC 96 ms
168,336 KB
testcase_41 AC 2 ms
5,392 KB
testcase_42 AC 178 ms
168,192 KB
testcase_43 AC 208 ms
168,432 KB
testcase_44 AC 207 ms
168,192 KB
testcase_45 AC 160 ms
168,288 KB
testcase_46 AC 163 ms
168,280 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using pii=pair<int,int>;

#define all(a) a.begin(),a.end()
#define pb push_back
#define sz(a) ((int)a.size())

const int maxn=200005,mod=998244353;
int add(int x, int y){x+=y; if(x>=mod) x-=mod; return x;}
int sub(int x, int y){x-=y; if(x<0) x+=mod; return x;}
int mul(int x, int y){return ((ll)x)*y%mod;}

int n,m,k,a[maxn],dp[2][maxn][105];

signed main(){
    ios_base::sync_with_stdio(0),cin.tie(0);
    cin >> n >> m >> k;
    for(int i=0; i<n; ++i) cin >> a[i];
    for(int i=0; i<n; ++i){
        if(i%m==0){
            dp[0][i][0]=1;
            dp[0][i][a[i]]=add(dp[0][i][a[i]],1);
            continue;
        }
        int cur=k-a[i];
        if(cur==k) cur=0;
        for(int j=0; j<k; ++j) dp[0][i][j]=add(dp[0][i-1][j],dp[0][i-1][cur]),cur=(cur+1==k?0:cur+1);
    }
    for(int i=n-1; i>=0; --i){
        if(i%m==m-1||i==n-1){
            dp[1][i][0]=1;
            dp[1][i][a[i]]=add(dp[1][i][a[i]],1);
            continue;
        }
        int cur=k-a[i];
        if(cur==k) cur=0;
        for(int j=0; j<k; ++j) dp[1][i][j]=add(dp[1][i+1][j],dp[1][i+1][cur]),cur=(cur+1==k?0:cur+1);
    }
    for(int i=0; i+m<=n; ++i){
        if(i%m==0) cout << sub(dp[0][i+m-1][0],1) << "\n";
        else{
            int res=sub(mul(dp[0][i+m-1][0],dp[1][i][0]),1);
            for(int j=1; j<k; ++j) res=add(res,mul(dp[0][i+m-1][j],dp[1][i][k-j]));
            cout << res << "\n";
        }
    }
}
0