結果
| 問題 | 
                            No.171 スワップ文字列(Med)
                             | 
                    
| コンテスト | |
| ユーザー | 
                             vain0
                         | 
                    
| 提出日時 | 2015-05-24 23:56:49 | 
| 言語 | C++11(廃止可能性あり)  (gcc 13.3.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 4 ms / 1,000 ms | 
| コード長 | 805 bytes | 
| コンパイル時間 | 716 ms | 
| コンパイル使用メモリ | 70,084 KB | 
| 実行使用メモリ | 7,424 KB | 
| 最終ジャッジ日時 | 2024-07-06 08:09:04 | 
| 合計ジャッジ時間 | 1,200 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge4 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 10 | 
ソースコード
#include <cmath>
#include <map>
#include <string>
#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;
#define repi(_I, _B, _E) for(int _I = (_B); (_I) < (_E); ++ (_I))
#define rep(_I, _N) for(int _I = 0; (_I) < (_N); ++ (_I))
static int const MOD = 573;
static int const COMBI_MAX = 1002;
static int combi[COMBI_MAX][COMBI_MAX];
int cnts['Z' - 'A' + 1];
int main() {
	string s;
	cin >> s;
	int n = s.size();
	rep(i, n) { cnts[s[i] - 'A'] ++; }
	rep(i, COMBI_MAX) repi(j, 0, i/2 + 1) {
		combi[i][j] = combi[i][i - j] =
			(i == 0 || j == 0) ? 1
			: (combi[i - 1][j] + combi[i - 1][j - 1]) % MOD;
	}
	int m = n;
	int res = 1;
	rep(i, 'Z' - 'A' + 1) {
		int r = cnts[i];
		res = (res * combi[m][r]) % MOD;
		m -= r;
	}
	cout << (res + MOD - 1) % MOD << endl;
	return 0;
}
            
            
            
        
            
vain0