結果

問題 No.2243 Coaching Schedule
ユーザー 沙耶花沙耶花
提出日時 2023-03-11 21:20:42
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,001 bytes
コンパイル時間 4,905 ms
コンパイル使用メモリ 269,748 KB
実行使用メモリ 8,696 KB
最終ジャッジ日時 2023-10-18 10:20:56
合計ジャッジ時間 12,918 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 100 ms
7,304 KB
testcase_06 AC 226 ms
7,304 KB
testcase_07 AC 211 ms
7,304 KB
testcase_08 AC 209 ms
7,304 KB
testcase_09 AC 332 ms
7,304 KB
testcase_10 AC 348 ms
7,304 KB
testcase_11 AC 346 ms
7,304 KB
testcase_12 TLE -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
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 -- -
権限があれば一括ダウンロードができます

ソースコード

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


int main(){
	
	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 /= 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