結果

問題 No.1533 Don't be Negative!
コンテスト
ユーザー leukocyte
提出日時 2022-07-02 12:26:49
言語 C++14
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++14 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 4,317 ms / 8,000 ms
コード長 640 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,419 ms
コンパイル使用メモリ 184,484 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2026-05-13 01:15:52
合計ジャッジ時間 84,071 ms
ジャッジサーバーID
(参考情報)
judge3_1 / judge1_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 53
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include<bits/stdc++.h>
using namespace std;
using ll=long long;
const int N=4e4,S=8e4;
const int mod=998244353;
int n,m,k;
int f[S+5],g[S+5];
int c[N+5];
int ans;
int main(){
	scanf("%d %d %d",&n,&m,&k);
	f[0]=1;
	int ms=2*m-(k>0),tmp=1;
	for(int i=1;i<=n;i++){
		int r=min(i,n-i)*m;
		ll s=0;
		for(int j=-m;j<m;j++) s+=f[abs(j)];
		for(int j=0;j<=r;j++){
			s+=f[j+m];
			if(k) g[j]=(s-f[j+k]-f[abs(j-k)])%mod;
			else g[j]=(s-f[j])%mod;
			s-=f[abs(j-m)];
		}
		memcpy(f,g,(r+1)*sizeof(int));
		tmp=1ll*tmp*ms%mod;
		int c=499122177ll*(tmp-f[0])%mod;
		ans=(1ll*ans*ms+1ll*c*(n-i+1))%mod;
	}
	printf("%d\n",(ans+mod)%mod);
	return 0;
}
0