結果

問題 No.171 スワップ文字列(Med)
ユーザー cocolleaguecocolleague
提出日時 2017-02-04 17:46:52
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 5 ms / 1,000 ms
コード長 607 bytes
コンパイル時間 1,234 ms
コンパイル使用メモリ 151,868 KB
実行使用メモリ 10,728 KB
最終ジャッジ日時 2023-08-25 20:13:00
合計ジャッジ時間 2,090 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
10,592 KB
testcase_01 AC 4 ms
10,728 KB
testcase_02 AC 5 ms
10,500 KB
testcase_03 AC 5 ms
10,604 KB
testcase_04 AC 4 ms
10,588 KB
testcase_05 AC 5 ms
10,528 KB
testcase_06 AC 5 ms
10,696 KB
testcase_07 AC 4 ms
10,600 KB
testcase_08 AC 5 ms
10,504 KB
testcase_09 AC 4 ms
10,508 KB
testcase_10 AC 4 ms
10,528 KB
testcase_11 AC 4 ms
10,520 KB
testcase_12 AC 5 ms
10,504 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
static const int INF = 1e8;
const ll MOD = 573;
ll cmb[1024][1024];
void comb(){
	cmb[0][0] = 1;
	for(int i = 0; i < 1024; i++){
		cmb[i][0] = 1;
		for(int j = 1;j <=i;j++){
			cmb[i][j] = (cmb[i-1][j]+cmb[i-1][j-1] % MOD);
		}
	}
}
int main(void){
	comb();
	string s;
	cin >> s;
	int n = s.size();
	map<char,int> m;
	for(char c: s){
		m[c]++;
	}
	ll ans = 1;
	for(auto el : m){
		ans *= cmb[n][el.second];
		n   -= el.second;
		ans %= MOD;
	}
	cout << (ans - 1 + MOD) % MOD << endl;
	return 0;

 }
0