結果

問題 No.171 スワップ文字列(Med)
ユーザー ttkkggwwttkkggww
提出日時 2022-08-18 21:10:39
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 13 ms / 1,000 ms
コード長 813 bytes
コンパイル時間 4,880 ms
コンパイル使用メモリ 255,860 KB
実行使用メモリ 19,288 KB
最終ジャッジ日時 2024-04-16 04:27:14
合計ジャッジ時間 5,415 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 12 ms
19,108 KB
testcase_01 AC 13 ms
19,200 KB
testcase_02 AC 13 ms
19,072 KB
testcase_03 AC 11 ms
19,200 KB
testcase_04 AC 11 ms
19,200 KB
testcase_05 AC 13 ms
19,192 KB
testcase_06 AC 11 ms
19,072 KB
testcase_07 AC 11 ms
18,944 KB
testcase_08 AC 12 ms
19,200 KB
testcase_09 AC 12 ms
19,072 KB
testcase_10 AC 13 ms
19,288 KB
testcase_11 AC 11 ms
19,200 KB
testcase_12 AC 12 ms
19,072 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#include<atcoder/all>
using namespace atcoder;
using ll = long long;
using mint = modint;
string s;
int cnt[26];
const int MAX_N = 2000;
mint fac[MAX_N],facinv[MAX_N];
mint biomv[2000][2000];
void init(){
	biomv[0][0] = 1;
	for(int i = 1;i<MAX_N;i++){
		biomv[i][0] = 1;
		for(int j = 1;j<MAX_N;j++){
			biomv[i][j] = biomv[i-1][j-1]+biomv[i-1][j];
		}
	}
}

mint biom(int n,int k){
	if(n<k)return 0;
	if (n < 0 || k < 0) return 0;
	return biomv[n][k];
}

void solve(){
	init();
	for(auto &c:s){
		cnt[c-'A'] ++;
	}
	mint ans = 1;
	int cur = s.size();
	for(int i = 0;i<26;i++){
		ans *= biom(cur,cnt[i]);
		cur -= cnt[i];
	}
	ans--;
	cout<<ans.val()<<endl;
}

signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cin >> s;
	mint::set_mod(573);
	solve();
}
0