結果

問題 No.171 スワップ文字列(Med)
ユーザー h_nosonh_noson
提出日時 2016-06-19 23:22:20
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 5 ms / 1,000 ms
コード長 882 bytes
コンパイル時間 530 ms
コンパイル使用メモリ 66,400 KB
実行使用メモリ 7,424 KB
最終ジャッジ日時 2024-04-19 13:02:36
合計ジャッジ時間 1,231 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
7,400 KB
testcase_01 AC 4 ms
7,276 KB
testcase_02 AC 3 ms
7,332 KB
testcase_03 AC 3 ms
7,296 KB
testcase_04 AC 4 ms
7,228 KB
testcase_05 AC 3 ms
7,296 KB
testcase_06 AC 4 ms
7,420 KB
testcase_07 AC 3 ms
7,288 KB
testcase_08 AC 4 ms
7,380 KB
testcase_09 AC 3 ms
7,256 KB
testcase_10 AC 3 ms
7,264 KB
testcase_11 AC 5 ms
7,424 KB
testcase_12 AC 4 ms
7,424 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;

#define REP(i,s,e) for (i = s; i <= e; i++)
#define rep(i,n) REP (i,0,(int)(n)-1)
#define RREP(i,s,e) for (i = s; i >= e; i--)
#define rrep(i,n) RREP (i,(int)(n)-1,0)
#define INF (int)1e8
#define MOD 573

typedef long long ll;

int comb[1001][1001];

int main(void) {
    string s;
    cin >> s;
    int alp[26] {};
    for (auto&& c : s) alp[c-'A']++;

    int i, j;
    rep (i,1001) REP (j,0,i) {
        if (j == 0)
            comb[i][j] = 1;
        else if (i == j)
            comb[i][j] = 1;
        else
            comb[i][j] = (comb[i-1][j] + comb[i-1][j-1]) % MOD;
    }
    int ans = 1;
    int n = s.size();
    rep (i,26) if (alp[i] > 0) {
        ans = (ans * comb[n][alp[i]]) % MOD;
        n -= alp[i];
    }
    cout << (ans + MOD - 1) % MOD << endl;
    return 0;
}
0