結果

問題 No.2215 Slide Subset Sum
ユーザー 沙耶花沙耶花
提出日時 2023-02-10 22:55:58
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 634 ms / 3,000 ms
コード長 914 bytes
コンパイル時間 4,620 ms
コンパイル使用メモリ 265,140 KB
実行使用メモリ 89,844 KB
最終ジャッジ日時 2023-09-22 00:04:18
合計ジャッジ時間 19,870 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 341 ms
4,384 KB
testcase_01 AC 578 ms
4,376 KB
testcase_02 AC 624 ms
4,380 KB
testcase_03 AC 634 ms
4,376 KB
testcase_04 AC 630 ms
5,680 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 3 ms
4,376 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 3 ms
4,376 KB
testcase_17 AC 450 ms
42,748 KB
testcase_18 AC 461 ms
37,148 KB
testcase_19 AC 624 ms
4,876 KB
testcase_20 AC 370 ms
47,136 KB
testcase_21 AC 587 ms
13,576 KB
testcase_22 AC 355 ms
50,344 KB
testcase_23 AC 254 ms
80,832 KB
testcase_24 AC 254 ms
81,148 KB
testcase_25 AC 283 ms
72,384 KB
testcase_26 AC 358 ms
50,588 KB
testcase_27 AC 31 ms
4,376 KB
testcase_28 AC 19 ms
5,984 KB
testcase_29 AC 37 ms
5,188 KB
testcase_30 AC 304 ms
4,376 KB
testcase_31 AC 81 ms
32,192 KB
testcase_32 AC 49 ms
4,628 KB
testcase_33 AC 396 ms
10,020 KB
testcase_34 AC 261 ms
23,472 KB
testcase_35 AC 101 ms
4,376 KB
testcase_36 AC 59 ms
15,688 KB
testcase_37 AC 224 ms
89,844 KB
testcase_38 AC 47 ms
14,804 KB
testcase_39 AC 583 ms
4,380 KB
testcase_40 AC 317 ms
4,376 KB
testcase_41 AC 2 ms
4,376 KB
testcase_42 AC 366 ms
46,848 KB
testcase_43 AC 610 ms
8,108 KB
testcase_44 AC 601 ms
8,036 KB
testcase_45 AC 296 ms
68,244 KB
testcase_46 AC 297 ms
68,272 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using mint = modint998244353;
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf32 1000000001
#define Inf64 1000000000000000001


int main(){
	int N,M,K;
	cin>>N>>M>>K;
	vector<int> a(N);
	rep(i,N)cin>>a[i];
	for(int i=M-1;i<N;i+=M+1){
		
		vector ldp(M+1,vector<mint>(K,0));
		ldp[0][0] = 1;
		rep(j,M){
			int A = a[i-j];
			rep(k,K){
				ldp[j+1][k] += ldp[j][k];
				ldp[j+1][(k+A)%K] += ldp[j][k];
			}
		}
				
		
		vector<mint> rdp(K,0);
		rdp[0] = 1;
		int cur = i+1;
		while(ldp.size()>0){
			mint ans = 0;
			rep(j,K){
				ans += ldp.back()[j] * rdp[(K-j)%K];
			}
			cout<<(ans-1).val()<<endl;
			ldp.pop_back();
			if(cur>=N)break;
			vector<mint> ndp(K,0);
			rep(j,K){
				ndp[j] += rdp[j];
				ndp[(j+a[cur])%K] += rdp[j];
			}
			swap(ndp,rdp);
			cur++;
		}
	}
	
	return 0;
}
0