結果
| 問題 | No.171 スワップ文字列(Med) | 
| コンテスト | |
| ユーザー |  yosupot | 
| 提出日時 | 2015-03-22 23:30:33 | 
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 14 ms / 1,000 ms | 
| コード長 | 768 bytes | 
| コンパイル時間 | 522 ms | 
| コンパイル使用メモリ | 68,008 KB | 
| 実行使用メモリ | 17,912 KB | 
| 最終ジャッジ日時 | 2024-06-29 00:11:18 | 
| 合計ジャッジ時間 | 1,247 ms | 
| ジャッジサーバーID (参考情報) | judge2 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 10 | 
ソースコード
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <cassert>
#include <cstdio>
 
using namespace std;
typedef long long ll;
int comb[1919][1919];
void init() {
    comb[0][0] = 1;
    for (int i = 1; i < 1919; i++) {
        comb[i][0] = 1;
        for (int j = 1; j < 1919; j++) {
            comb[i][j] = (comb[i-1][j] + comb[i-1][j-1]) % 573;
        }
    }
}
int d[26];
int main() {
    init();
    string s;
    cin >> s;
    int n = (int)s.size();
    for (char c: s) {
        d[c-'A']++;
    }
    ll res = 1;
    for (int i = 0; i < 26; i++) {
        res *= comb[n][d[i]];
        n -= d[i];
        res %= 573;
    }
    cout << (res + 572) % 573 << endl;
    return 0;
}
            
            
            
        