結果
| 問題 | No.171 スワップ文字列(Med) | 
| コンテスト | |
| ユーザー |  ty70 | 
| 提出日時 | 2015-03-23 02:04:14 | 
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 8 ms / 1,000 ms | 
| コード長 | 2,074 bytes | 
| コンパイル時間 | 769 ms | 
| コンパイル使用メモリ | 96,012 KB | 
| 実行使用メモリ | 11,264 KB | 
| 最終ジャッジ日時 | 2024-06-29 00:21:37 | 
| 合計ジャッジ時間 | 1,410 ms | 
| ジャッジサーバーID (参考情報) | judge2 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 10 | 
ソースコード
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()
#define each(i,c) for(auto i=(c).begin();i!=(c).end();++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define clr(a) memset((a),0,sizeof(a))
#define nclr(a) memset((a),-1,sizoef(a))
#define sz(s) (int)((s).size())
#define INRANGE(x,s,e) ((s)<=(x) && (x)<(e))
#define pb push_back
#define MP(x,y) make_pair((x),(y))
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll MOD = 573LL;
const int MAX_P=1005;
ll dp[1005][1005];
void init_comb (void ){
	memset (dp, 0LL, sizeof (dp ) );
	rep (i, 1005 ) dp[i][0] = 1LL;
	rep (j, 1005 ) dp[0][j] = 1LL;
	for (int k = 1; k < 1005; k++ ){
		for (int j = 1; j <= k; j++ ){
			int i = k - (j-1);
			dp[i][j] = (dp[i][j-1]+dp[i-1][j]) % MOD;
		} // end for
	} // end for
}
int main()
{
	init_comb();
#if 0
	rep (i, 10 ){
		rep (j, 10 ){
			cerr << dp[i][j] << (j != 10 - 1 ? '\t' : '\n' );
		} // end rep
	} // end rep
#endif
	ios_base::sync_with_stdio(0);
	string S = ""; cin >> S;
	map<char,int> cnt; cnt.clear();
	int n = S.length();
	rep (i, n ){
		cnt[S[i]]++;
	} // end rep
	ll res = 1LL;
	map<char,int>::iterator it = cnt.begin();
	for(; it != cnt.end(); it++ ){
		char c = (*it).first;
		int  k = (*it).second;
		res = (res*dp[n-k][k] )%MOD;
		n -= k;
	} // end for
	cout << (res - 1LL + MOD ) % MOD << endl;
	return 0;
}
            
            
            
        