結果

問題 No.171 スワップ文字列(Med)
ユーザー tkzw_21tkzw_21
提出日時 2015-03-22 23:55:44
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 12 ms / 1,000 ms
コード長 670 bytes
コンパイル時間 1,139 ms
コンパイル使用メモリ 146,212 KB
実行使用メモリ 10,580 KB
最終ジャッジ日時 2023-09-11 09:38:04
合計ジャッジ時間 1,967 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
10,320 KB
testcase_01 AC 12 ms
10,344 KB
testcase_02 AC 11 ms
10,336 KB
testcase_03 AC 11 ms
10,344 KB
testcase_04 AC 11 ms
10,344 KB
testcase_05 AC 11 ms
10,304 KB
testcase_06 AC 12 ms
10,572 KB
testcase_07 AC 11 ms
10,288 KB
testcase_08 AC 11 ms
10,572 KB
testcase_09 AC 12 ms
10,528 KB
testcase_10 AC 12 ms
10,336 KB
testcase_11 AC 11 ms
10,580 KB
testcase_12 AC 11 ms
10,512 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;

long long nCr[1010][1010];

int main(void) {
	string s;
	cin >> s;
	int n = s.size();
	vector<int> cnt(26);
	for(int i=0;i<s.size();i++){
		cnt[s[i]-'A']++;
	}

	nCr[0][0] = 1;
	for(int i=0;i<=1000;i++) for(int j=0;j<i+1;j++) {
		nCr[i + 1][j] += nCr[i][j];
		nCr[i + 1][j + 1] += nCr[i][j];
		nCr[i+1][j] %= 573;
		nCr[i+1][j+1] %= 573;
	}
	ll ret = 1;
	for(int i=0;i<26;i++){
		ll t = nCr[n][cnt[i]];
		if(n == 0 || cnt[i] == 0)t = 1;
		ret *= t;
		ret %= 573;
		n -= cnt[i];
	}
	if(ret == 0)cout << 572 << endl;
	else cout << ret-1 << endl;

	return 0;
}
0