結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 652 ms
324,312 KB
testcase_01 WA -
testcase_02 AC 952 ms
324,444 KB
testcase_03 AC 954 ms
324,348 KB
testcase_04 AC 939 ms
324,332 KB
testcase_05 AC 3 ms
7,476 KB
testcase_06 AC 2 ms
7,544 KB
testcase_07 WA -
testcase_08 AC 2 ms
7,448 KB
testcase_09 AC 3 ms
7,452 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 3 ms
7,780 KB
testcase_13 AC 3 ms
8,060 KB
testcase_14 AC 3 ms
7,840 KB
testcase_15 AC 2 ms
7,472 KB
testcase_16 AC 5 ms
8,412 KB
testcase_17 AC 1,006 ms
435,348 KB
testcase_18 AC 897 ms
374,396 KB
testcase_19 AC 957 ms
326,024 KB
testcase_20 AC 765 ms
324,800 KB
testcase_21 AC 908 ms
326,232 KB
testcase_22 AC 793 ms
349,468 KB
testcase_23 MLE -
testcase_24 MLE -
testcase_25 AC 995 ms
510,540 KB
testcase_26 AC 807 ms
350,668 KB
testcase_27 AC 57 ms
30,072 KB
testcase_28 AC 119 ms
96,180 KB
testcase_29 AC 73 ms
35,592 KB
testcase_30 AC 509 ms
189,284 KB
testcase_31 AC 420 ms
243,856 KB
testcase_32 AC 84 ms
35,088 KB
testcase_33 AC 673 ms
272,448 KB
testcase_34 AC 679 ms
370,896 KB
testcase_35 AC 208 ms
107,648 KB
testcase_36 AC 198 ms
104,072 KB
testcase_37 AC 589 ms
324,380 KB
testcase_38 AC 354 ms
324,364 KB
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 AC 776 ms
324,328 KB
testcase_43 AC 938 ms
324,372 KB
testcase_44 AC 942 ms
324,352 KB
testcase_45 AC 958 ms
481,076 KB
testcase_46 AC 963 ms
481,080 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];

ll from[101];
ll to[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<<1+(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