結果

問題 No.1533 Don't be Negative!
ユーザー SuiseisekiSuiseiseki
提出日時 2022-07-02 18:36:48
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,310 bytes
コンパイル時間 331 ms
コンパイル使用メモリ 45,108 KB
実行使用メモリ 8,768 KB
最終ジャッジ日時 2023-08-18 10:14:35
合計ジャッジ時間 23,311 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
7,476 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 77 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 3,335 ms
4,380 KB
testcase_12 AC 3,459 ms
4,376 KB
testcase_13 AC 486 ms
4,376 KB
testcase_14 AC 1,635 ms
4,380 KB
testcase_15 AC 3,932 ms
4,380 KB
testcase_16 TLE -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
testcase_49 -- -
testcase_50 -- -
testcase_51 -- -
testcase_52 -- -
testcase_53 -- -
testcase_54 -- -
testcase_55 -- -
testcase_56 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <algorithm>
const int Maxn=80000;
const int Mod=998244353;
const int inv_2=(Mod+1)/2;
int f[2][Maxn+6];
int n,m,k;
int pow_v[Maxn+5];
int main(){
	scanf("%d%d%d",&n,&m,&k);
	int cur=0,nxt;
	f[cur][0]=1;
	pow_v[0]=1;
	for(int i=1;i<=n;i++){
		pow_v[i]=1ll*pow_v[i-1]*(2*m-1+(k==0))%Mod;
	}
	int ans=0;
	for(int i=1;i<=n;i++){
		nxt=cur^1;
		int cur_len=std::min(i-1,n-i+1)*m,nxt_len=std::min(i,n-i)*m;
		int sum=0;
		for(int j=0;j<=nxt_len;j++){
			sum=(sum+f[cur][j])%Mod;
			if(j-m-1>=0){
				sum=(sum-f[cur][j-m-1]+Mod)%Mod;
			}
			f[nxt][j]=sum;
			if(j-k>=0){
				f[nxt][j]=(f[nxt][j]-f[cur][j-k]+Mod)%Mod;
			}
		}
		sum=0;
		for(int j=cur_len;j>=-m;j--){
			if((k==0&&j+1>=0)||j+1>0){
				sum=(sum+f[cur][j+1])%Mod;
			}
			if(j+m+1<=cur_len){
				sum=(sum-f[cur][j+m+1]+Mod)%Mod;
			}
			int nxt_j=std::abs(j);
			if(nxt_j<=nxt_len){
				f[nxt][nxt_j]=(f[nxt][nxt_j]+sum)%Mod;
				if(k>0&&j+k>0&&std::abs(j+k)<=cur_len){
					f[nxt][nxt_j]=(f[nxt][nxt_j]-f[cur][std::abs(j+k)]+Mod)%Mod;
				}
			}
		}
		if(k!=0){
			f[nxt][0]=(2ll*f[nxt][0]-f[cur][0]+Mod)%Mod;
		}
		memset(f[cur],0,(cur_len+1)*sizeof(int));
		cur=nxt;
		int val=1ll*(pow_v[i]-f[cur][0]+Mod)*inv_2%Mod;
		ans=(ans+1ll*pow_v[n-i]*val%Mod*(n-i+1))%Mod;
	}
	printf("%d\n",ans);
	return 0;
}
0