結果

問題 No.2243 Coaching Schedule
ユーザー 沙耶花沙耶花
提出日時 2023-03-11 21:21:58
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 558 ms / 4,000 ms
コード長 1,070 bytes
コンパイル時間 4,936 ms
コンパイル使用メモリ 269,728 KB
実行使用メモリ 8,484 KB
最終ジャッジ日時 2023-10-18 10:21:08
合計ジャッジ時間 11,478 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
4,920 KB
testcase_01 AC 42 ms
4,924 KB
testcase_02 AC 43 ms
4,924 KB
testcase_03 AC 42 ms
4,920 KB
testcase_04 AC 43 ms
4,988 KB
testcase_05 AC 126 ms
8,484 KB
testcase_06 AC 151 ms
8,484 KB
testcase_07 AC 151 ms
8,484 KB
testcase_08 AC 150 ms
8,484 KB
testcase_09 AC 172 ms
8,484 KB
testcase_10 AC 172 ms
8,484 KB
testcase_11 AC 173 ms
8,484 KB
testcase_12 AC 558 ms
8,484 KB
testcase_13 AC 447 ms
8,484 KB
testcase_14 AC 451 ms
8,484 KB
testcase_15 AC 447 ms
8,484 KB
testcase_16 AC 123 ms
8,484 KB
testcase_17 AC 73 ms
5,808 KB
testcase_18 AC 121 ms
8,024 KB
testcase_19 AC 159 ms
8,044 KB
testcase_20 AC 130 ms
6,496 KB
testcase_21 AC 89 ms
6,500 KB
testcase_22 AC 83 ms
6,400 KB
testcase_23 AC 48 ms
5,268 KB
testcase_24 AC 106 ms
6,588 KB
testcase_25 AC 51 ms
5,248 KB
testcase_26 AC 65 ms
5,960 KB
testcase_27 AC 111 ms
6,624 KB
testcase_28 AC 52 ms
5,268 KB
testcase_29 AC 131 ms
7,760 KB
testcase_30 AC 138 ms
8,188 KB
testcase_31 AC 142 ms
8,364 KB
testcase_32 AC 81 ms
6,276 KB
testcase_33 AC 67 ms
6,140 KB
testcase_34 AC 120 ms
7,868 KB
testcase_35 AC 137 ms
7,976 KB
testcase_36 AC 134 ms
8,216 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
using mint = modint998244353;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf32 1000000001
#define Inf64 4000000000000000001

mint iv[300000];
int main(){
	for(int i=1;i<300000;i++)iv[i] = mint(i).inv();
	
	int M,N;
	cin>>M>>N;
	
	vector<int> c(M);
	rep(i,N){
		int a;
		cin>>a;
		c[a-1]++;
	}
	
	vector<int> d(N+1);
	rep(i,c.size()){
		d[c[i]]++;
	}
	
	vector<mint> num(N+1,1);
	for(int i=1;i<=N;i++){
		if(d[i]==0)continue;
		mint t = 1;
		rep(j,i)t *= j+1;
		for(int j=i;j<=N;j++){
			num[j] *= t.pow(d[i]);
			t *= j+1;
			t *= iv[j-i+1];
		}
		rep(j,i)num[j] = 0;
		
	}
	vector<mint> x(N+1,0);
	x[0] = 1;
	{
		mint c = 1;
		for(int i=1;i<=N;i++){
			c /= i;
			if(i%2==0)x[i] = c;
			else x[i] = -c;
		}
	}
	{
		mint c = 1;
		for(int i=1;i<=N;i++){
			c /= i;
			num[i] *= c;
		}
	}
	x = convolution(x,num);
	mint ans= 0;
	{
		mint c = 1;
		for(int i=1;i<=N;i++){
			c *= i;
			ans += x[i]*c;
		}
	}
	
	cout<<ans.val()<<endl;
	
	return 0;
}
0