結果

問題 No.171 スワップ文字列(Med)
ユーザー mayoko_mayoko_
提出日時 2015-03-23 08:13:25
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 5 ms / 1,000 ms
コード長 789 bytes
コンパイル時間 1,238 ms
コンパイル使用メモリ 152,080 KB
実行使用メモリ 10,700 KB
最終ジャッジ日時 2023-09-11 09:44:21
合計ジャッジ時間 2,045 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
10,512 KB
testcase_01 AC 5 ms
10,700 KB
testcase_02 AC 5 ms
10,640 KB
testcase_03 AC 5 ms
10,628 KB
testcase_04 AC 5 ms
10,500 KB
testcase_05 AC 5 ms
10,580 KB
testcase_06 AC 4 ms
10,512 KB
testcase_07 AC 4 ms
10,644 KB
testcase_08 AC 5 ms
10,524 KB
testcase_09 AC 5 ms
10,500 KB
testcase_10 AC 5 ms
10,536 KB
testcase_11 AC 5 ms
10,584 KB
testcase_12 AC 5 ms
10,588 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

#define rep(i, n) for (int (i) = 0; (i) < (int)(n); (i)++)

const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
using namespace std;
typedef long long ll;

const ll MOD = 573;
const int MAXN = 1024;
ll cmb[MAXN][MAXN];

void init() {
    cmb[0][0] = 1;
    for (int i = 1; i < MAXN; 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() {
    init();
    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