結果

問題 No.2215 Slide Subset Sum
ユーザー 👑 kmjpkmjp
提出日時 2023-02-10 22:46:33
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
MLE  
実行時間 -
コード長 1,571 bytes
コンパイル時間 2,140 ms
コンパイル使用メモリ 201,640 KB
実行使用メモリ 575,556 KB
最終ジャッジ日時 2023-09-21 23:55:45
合計ジャッジ時間 28,608 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 644 ms
324,332 KB
testcase_01 AC 262 ms
5,408 KB
testcase_02 AC 953 ms
324,348 KB
testcase_03 AC 942 ms
324,340 KB
testcase_04 AC 924 ms
324,536 KB
testcase_05 AC 2 ms
7,460 KB
testcase_06 AC 3 ms
7,564 KB
testcase_07 AC 2 ms
5,616 KB
testcase_08 AC 2 ms
7,532 KB
testcase_09 AC 2 ms
7,516 KB
testcase_10 AC 2 ms
5,408 KB
testcase_11 AC 2 ms
5,612 KB
testcase_12 AC 3 ms
7,684 KB
testcase_13 AC 3 ms
8,080 KB
testcase_14 AC 3 ms
7,676 KB
testcase_15 AC 3 ms
7,564 KB
testcase_16 AC 5 ms
8,348 KB
testcase_17 AC 1,011 ms
435,412 KB
testcase_18 AC 882 ms
374,224 KB
testcase_19 AC 961 ms
326,000 KB
testcase_20 AC 757 ms
324,828 KB
testcase_21 AC 904 ms
326,440 KB
testcase_22 AC 803 ms
349,400 KB
testcase_23 MLE -
testcase_24 MLE -
testcase_25 AC 970 ms
510,532 KB
testcase_26 AC 792 ms
350,668 KB
testcase_27 AC 54 ms
30,100 KB
testcase_28 AC 111 ms
96,152 KB
testcase_29 AC 70 ms
35,440 KB
testcase_30 AC 494 ms
189,288 KB
testcase_31 AC 403 ms
244,056 KB
testcase_32 AC 80 ms
35,240 KB
testcase_33 AC 661 ms
272,468 KB
testcase_34 AC 668 ms
370,948 KB
testcase_35 AC 201 ms
107,644 KB
testcase_36 AC 186 ms
104,212 KB
testcase_37 AC 597 ms
324,400 KB
testcase_38 AC 346 ms
324,472 KB
testcase_39 AC 269 ms
5,476 KB
testcase_40 AC 259 ms
5,408 KB
testcase_41 AC 2 ms
5,616 KB
testcase_42 AC 765 ms
324,340 KB
testcase_43 AC 935 ms
324,392 KB
testcase_44 AC 934 ms
324,568 KB
testcase_45 AC 937 ms
481,076 KB
testcase_46 AC 939 ms
481,128 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define FORR2(x,y,arr) for(auto& [x,y]:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
template<class T> bool chmax(T &a, const T &b) { if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a, const T &b) { if(a>b){a=b;return 1;}return 0;}
//-------------------------------------------------------

int N,M,K;
int A[402020];

ll L[404040][101];
ll R[404040][101];

const ll mo=998244353;
void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>M>>K;
	FOR(i,N) cin>>A[i];
	
	if(M==1) {
		FOR(i,N) {
			cout<<(A[i]==0)<<endl;
		}
		return;
	}
	
	int ON=N;
	N=(N+M-1)/M*M;
	FOR(i,N) {
		if(i%M==0) {
			ZERO(L[i]);
			L[i][0]=1;
		}
		FOR(j,K) {
			(L[i+1][j]+=L[i][j])%=mo;;
			(L[i+1][(j+A[i])%K]+=L[i][j])%=mo;
		}
	}
	for(i=N;i>=1;i--) {
		if(i%M==0) {
			ZERO(R[i]);
			R[i][0]=1;
		}
		FOR(j,K) {
			(R[i-1][j]+=R[i][j])%=mo;;
			(R[i-1][(j+A[i-1])%K]+=R[i][j])%=mo;
		}
	}
	for(i=0;i+M<=ON;i++) {
		ll ret=mo-1;
		if(i%M==0) {
			FOR(j,K) ret+=L[i+1][j]*R[i+1][(K-j)%K]%mo;
		}
		else {
			FOR(j,K) ret+=R[i][j]*L[i+M][(K-j)%K]%mo;
		}
		cout<<ret%mo<<endl;
	}
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}
0