結果

問題 No.1963 Subset Mex
ユーザー leukocyteleukocyte
提出日時 2022-07-02 09:15:20
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 24 ms / 4,000 ms
コード長 952 bytes
コンパイル時間 1,519 ms
コンパイル使用メモリ 165,900 KB
実行使用メモリ 7,956 KB
最終ジャッジ日時 2023-08-17 22:07:21
合計ジャッジ時間 3,493 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,556 KB
testcase_04 AC 3 ms
4,484 KB
testcase_05 AC 3 ms
4,440 KB
testcase_06 AC 3 ms
4,684 KB
testcase_07 AC 3 ms
4,540 KB
testcase_08 AC 3 ms
4,556 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,384 KB
testcase_12 AC 8 ms
7,932 KB
testcase_13 AC 7 ms
7,876 KB
testcase_14 AC 8 ms
7,796 KB
testcase_15 AC 9 ms
7,956 KB
testcase_16 AC 9 ms
7,756 KB
testcase_17 AC 10 ms
7,824 KB
testcase_18 AC 13 ms
7,804 KB
testcase_19 AC 17 ms
7,756 KB
testcase_20 AC 18 ms
7,676 KB
testcase_21 AC 22 ms
7,820 KB
testcase_22 AC 24 ms
7,808 KB
testcase_23 AC 24 ms
7,804 KB
testcase_24 AC 21 ms
7,812 KB
testcase_25 AC 21 ms
7,792 KB
testcase_26 AC 11 ms
7,940 KB
testcase_27 AC 14 ms
7,920 KB
testcase_28 AC 17 ms
7,832 KB
testcase_29 AC 14 ms
7,820 KB
権限があれば一括ダウンロードができます

ソースコード

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]=min(n+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&&tj<=n) inc(f[i][tj][tk],f[i+1][j][k]);
				}
			}
	}
	printf("%d\n",(ans+1)%mod);
	return 0;
}
0