結果

問題 No.171 スワップ文字列(Med)
ユーザー kyunakyuna
提出日時 2019-08-19 19:30:04
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 9 ms / 1,000 ms
コード長 752 bytes
コンパイル時間 759 ms
コンパイル使用メモリ 76,716 KB
実行使用メモリ 11,264 KB
最終ジャッジ日時 2024-04-15 07:07:59
合計ジャッジ時間 1,742 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 9 ms
11,136 KB
testcase_01 AC 9 ms
11,264 KB
testcase_02 AC 9 ms
11,136 KB
testcase_03 AC 9 ms
11,136 KB
testcase_04 AC 8 ms
11,264 KB
testcase_05 AC 8 ms
11,264 KB
testcase_06 AC 9 ms
11,136 KB
testcase_07 AC 8 ms
11,264 KB
testcase_08 AC 8 ms
11,136 KB
testcase_09 AC 8 ms
11,136 KB
testcase_10 AC 9 ms
11,264 KB
testcase_11 AC 8 ms
11,136 KB
testcase_12 AC 9 ms
11,136 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
const int MOD = 573;

vector<vector<long long>> get_combination(int ma) {
    vector<vector<long long>> mat(ma + 1, vector<long long>(ma + 1));
    for (int n = 0; n <= ma; n++) mat[n][0] = 1;
    for (int n = 1; n <= ma; n++) for (int r = 1; r <= n; r++) {
        mat[n][r] = (mat[n - 1][r - 1] + mat[n - 1][r]) % MOD;
    }
    return mat;
}

int main() {
    string s; cin >> s;
    vector<int> cnt(26);
    for (char c: s) cnt[c - 'A']++;
    vector<vector<long long>> comb = get_combination(1000);
    int ans = 1, n = s.size();
    for (int i = 0; i < 26; i++) (ans *= comb[n][cnt[i]]) %= MOD, n -= cnt[i];
    cout << (ans - 1 + MOD) % MOD << endl;
    return 0;
}
0