結果

問題 No.1533 Don't be Negative!
ユーザー SuiseisekiSuiseiseki
提出日時 2022-07-02 18:49:30
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 5,687 ms / 8,000 ms
コード長 942 bytes
コンパイル時間 721 ms
コンパイル使用メモリ 45,876 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-19 18:12:20
合計ジャッジ時間 108,772 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 11 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 1 ms
5,376 KB
testcase_10 AC 1 ms
5,376 KB
testcase_11 AC 612 ms
5,376 KB
testcase_12 AC 468 ms
5,376 KB
testcase_13 AC 69 ms
5,376 KB
testcase_14 AC 226 ms
5,376 KB
testcase_15 AC 534 ms
5,376 KB
testcase_16 AC 1,997 ms
5,376 KB
testcase_17 AC 63 ms
5,376 KB
testcase_18 AC 1,781 ms
5,376 KB
testcase_19 AC 146 ms
5,376 KB
testcase_20 AC 2,085 ms
5,376 KB
testcase_21 AC 271 ms
5,376 KB
testcase_22 AC 1,814 ms
5,376 KB
testcase_23 AC 1,140 ms
5,376 KB
testcase_24 AC 1,008 ms
5,376 KB
testcase_25 AC 1,245 ms
5,376 KB
testcase_26 AC 151 ms
5,376 KB
testcase_27 AC 1,383 ms
5,376 KB
testcase_28 AC 2,614 ms
5,376 KB
testcase_29 AC 1,853 ms
5,376 KB
testcase_30 AC 5,039 ms
5,376 KB
testcase_31 AC 30 ms
5,376 KB
testcase_32 AC 337 ms
5,376 KB
testcase_33 AC 2,082 ms
5,376 KB
testcase_34 AC 12 ms
5,376 KB
testcase_35 AC 1,317 ms
5,376 KB
testcase_36 AC 2,118 ms
5,376 KB
testcase_37 AC 239 ms
5,376 KB
testcase_38 AC 4,850 ms
5,376 KB
testcase_39 AC 3,428 ms
5,376 KB
testcase_40 AC 3,711 ms
5,376 KB
testcase_41 AC 2,947 ms
5,376 KB
testcase_42 AC 4,021 ms
5,376 KB
testcase_43 AC 3,596 ms
5,376 KB
testcase_44 AC 2,494 ms
5,376 KB
testcase_45 AC 3,104 ms
5,376 KB
testcase_46 AC 3,144 ms
5,376 KB
testcase_47 AC 2,876 ms
5,376 KB
testcase_48 AC 3,647 ms
5,376 KB
testcase_49 AC 3,679 ms
5,376 KB
testcase_50 AC 5,464 ms
5,376 KB
testcase_51 AC 5,004 ms
5,376 KB
testcase_52 AC 2,699 ms
5,376 KB
testcase_53 AC 4,054 ms
5,376 KB
testcase_54 AC 5,687 ms
5,376 KB
testcase_55 AC 5,676 ms
5,376 KB
testcase_56 AC 5,682 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <algorithm>
typedef long long ll;
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;
		ll sum=0;
		for(int j=-m;j<m;j++){
			sum+=f[cur][std::abs(j)];
		}
		for(int j=0;j<=nxt_len;j++){
			sum+=f[cur][j+m];
			if(k==0){
				f[nxt][j]=(sum-f[cur][j])%Mod;
			}
			else{
				f[nxt][j]=(sum-f[cur][std::abs(j-k)]-f[cur][j+k])%Mod;
			}
			sum-=f[cur][std::abs(j-m)];
		}
		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