結果

問題 No.171 スワップ文字列(Med)
ユーザー mamekinmamekin
提出日時 2015-04-05 16:31:23
言語 C++11
(gcc 13.3.0)
結果
AC  
実行時間 5 ms / 1,000 ms
コード長 1,102 bytes
コンパイル時間 758 ms
コンパイル使用メモリ 98,516 KB
実行使用メモリ 7,424 KB
最終ジャッジ日時 2024-07-04 02:06:04
合計ジャッジ時間 1,331 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

const int MOD = 573;

void combination(int n, vector<vector<int> >& comb)
{
    comb.assign(n+1, vector<int>(n+1, 0));
    for(int i=0; i<=n; ++i){
        comb[i][0] = 1;
        for(int j=1; j<=i; ++j){
            comb[i][j] = comb[i-1][j-1] + comb[i-1][j];
            comb[i][j] %= MOD;
        }
    }
}

int main()
{
    string s;
    cin >> s;
    int n = s.size();

    vector<int> cnt(128, 0);
    for(int i=0; i<n; ++i)
        ++ cnt[s[i]];

    vector<vector<int> > comb;
    combination(n, comb);

    int ans = 1;
    for(char c='A'; c<='Z'; ++c){
        ans *= comb[n][cnt[c]];
        ans %= MOD;
        n -= cnt[c];
    }

    ans = (ans - 1 + MOD) % MOD;
    cout << ans << endl;

    return 0;
}
0