結果

問題 No.171 スワップ文字列(Med)
ユーザー srjywrdnprktsrjywrdnprkt
提出日時 2022-12-25 20:37:31
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 13 ms / 1,000 ms
コード長 928 bytes
コンパイル時間 1,084 ms
コンパイル使用メモリ 109,564 KB
実行使用メモリ 11,356 KB
最終ジャッジ日時 2023-08-12 10:55:08
合計ジャッジ時間 2,119 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 12 ms
11,180 KB
testcase_01 AC 12 ms
11,276 KB
testcase_02 AC 13 ms
11,288 KB
testcase_03 AC 13 ms
11,248 KB
testcase_04 AC 13 ms
11,232 KB
testcase_05 AC 13 ms
11,184 KB
testcase_06 AC 13 ms
11,244 KB
testcase_07 AC 13 ms
11,264 KB
testcase_08 AC 13 ms
11,244 KB
testcase_09 AC 13 ms
11,252 KB
testcase_10 AC 13 ms
11,356 KB
testcase_11 AC 13 ms
11,224 KB
testcase_12 AC 13 ms
11,184 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <cmath>
#include <map>
#include <set>
#include <iomanip>
#include <queue>
#include <algorithm>
#include <numeric>
#include <deque>

using namespace std;

vector<vector<long long>> comb;

void combinations(long long n, long long modc=573){
    comb.resize(n+1);
    for (long long i=0; i<=n; i++){
        comb[i].resize(n+1);
        comb[i][0] = 1;
    }   

    for (long long i=1; i <= n; i++){
        for (long long j=1; j <= i; j++){
            comb[i][j] = (comb[i-1][j-1] + comb[i-1][j]) % modc;
        }   
    }   
}

int main(){

    combinations(1000);

    long long tot=0, ans=1, N;
    string S;
    cin >> S;
    N = S.size();
    vector<long long> cnt(26);
    for (auto x : S) cnt[x-'A']++;
    for (int i=0; i<26; i++){
        ans *= comb[N-tot][cnt[i]];
        ans %= 573;
        tot += cnt[i];
    }

    cout << (ans+572) % 573 << endl;

    return 0;
}
0