結果

問題 No.171 スワップ文字列(Med)
ユーザー BantakoBantako
提出日時 2018-12-30 17:22:26
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 7 ms / 1,000 ms
コード長 876 bytes
コンパイル時間 1,650 ms
コンパイル使用メモリ 164,516 KB
実行使用メモリ 7,552 KB
最終ジャッジ日時 2024-04-16 20:54:41
合計ジャッジ時間 2,294 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 6 ms
7,552 KB
testcase_01 AC 6 ms
7,424 KB
testcase_02 AC 6 ms
7,552 KB
testcase_03 AC 7 ms
7,552 KB
testcase_04 AC 6 ms
7,424 KB
testcase_05 AC 7 ms
7,552 KB
testcase_06 AC 7 ms
7,552 KB
testcase_07 AC 6 ms
7,552 KB
testcase_08 AC 7 ms
7,424 KB
testcase_09 AC 7 ms
7,552 KB
testcase_10 AC 6 ms
7,424 KB
testcase_11 AC 6 ms
7,552 KB
testcase_12 AC 6 ms
7,552 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:22:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   22 | main(){
      | ^~~~

ソースコード

diff #

#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 573;
int table[1001][1001];
int charsearch(string s,char c){
    //文字cが文字列sに含まれるかどうか
    int cnt = 0;
    rep(i, 0, s.length()){
        if(s[i] == c)cnt++;;
    }
    return cnt;
}
int combi(int n, int r){
    if(n < r){
        return -1;
    }
    return table[n][r];
}
main(){
    rep(i,0,1001)rep(j,0,i+1){
        if(i == 0 || j == 0 || j == i)table[i][j] = 1;
        else{
            table[i][j] = (table[i-1][j-1] + table[i-1][j]) % MOD;
        }
    }
    string S;
    cin >> S;
    ll ans = 1;
    int n = S.size();
    rep(i,0,26){
        ans = ans * combi(n, charsearch(S,i + 'A')) % MOD;
        n -= charsearch(S,i + 'A');
    }
    cout << (ans - 1 + MOD) % MOD << endl;
}
0