結果

問題 No.1963 Subset Mex
ユーザー leukocyteleukocyte
提出日時 2022-07-02 09:07:54
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 936 bytes
コンパイル時間 1,523 ms
コンパイル使用メモリ 166,136 KB
実行使用メモリ 8,072 KB
最終ジャッジ日時 2023-08-17 21:53:37
合計ジャッジ時間 3,346 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,428 KB
testcase_04 AC 3 ms
4,464 KB
testcase_05 AC 3 ms
4,448 KB
testcase_06 AC 4 ms
4,768 KB
testcase_07 AC 3 ms
4,520 KB
testcase_08 AC 3 ms
4,648 KB
testcase_09 AC 3 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 3 ms
4,384 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
const int N=1e2;
const int mod=998244353;
void inc(int &x,int y){ if((x+=y)>=mod) x-=mod; }
int n;
int f[N+5][N+5][N+5];
int c[N+5],mn=N+1;
int g[N+5];
int use(int x){
	if(!x) return 0;
	int s=0;
	g[x-1]=1;
	for(int i=x-1;i;i--){
		if(c[i]>=g[i]) s+=c[i]-g[i];
		g[i-1]=max(g[i],2*g[i]-c[i]);
	}
	return g[0]-c[0]-s;
}
int main(){
	scanf("%d",&n);
	for(int i=1,x;i<=n;i++){
		scanf("%d",&x);
		if(x==1) x=0;
		c[x]++; mn=min(mn,x);
	}
	int ans=0;
	f[N+1][0][0]=1;
	for(int i=N;i>=0;i--){
		int tu=use(i);
		for(int j=0;j*(i+1)<=n;j++)
			for(int k=0;k<=n;k++){
				if(!f[i+1][j][k]) continue;
				for(int t=0;t<=n;t++){
					int tj=max(j,j*2+t-c[i]),tk=k+max(0,c[i]-j-t);
					if(!i&&tj>0&&c[i]+k>=j+t) inc(ans,f[i+1][j][k]);
					if((i!=mn||tk>0)&&!tj&&t>0&&tk+1>=tu) inc(ans,f[i+1][j][k]);
					if(i) inc(f[i][tj][tk],f[i+1][j][k]);
				}
			}
	}
	printf("%d\n",(ans+1)%mod);
	return 0;
}
0