結果

問題 No.171 スワップ文字列(Med)
ユーザー EmKjpEmKjp
提出日時 2015-03-22 23:41:12
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 7 ms / 1,000 ms
コード長 1,139 bytes
コンパイル時間 557 ms
コンパイル使用メモリ 78,796 KB
実行使用メモリ 8,312 KB
最終ジャッジ日時 2023-09-11 09:35:13
合計ジャッジ時間 1,371 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 7 ms
8,284 KB
testcase_01 AC 6 ms
8,184 KB
testcase_02 AC 7 ms
8,272 KB
testcase_03 AC 7 ms
8,216 KB
testcase_04 AC 6 ms
8,156 KB
testcase_05 AC 7 ms
8,216 KB
testcase_06 AC 6 ms
8,156 KB
testcase_07 AC 6 ms
8,312 KB
testcase_08 AC 7 ms
8,260 KB
testcase_09 AC 6 ms
8,212 KB
testcase_10 AC 7 ms
8,196 KB
testcase_11 AC 7 ms
8,156 KB
testcase_12 AC 7 ms
8,228 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<numeric>
#include<functional>
#include<complex>

using namespace std;
#define BET(a,b,c) ((a)<=(b)&&(b)<(c))
#define FOR(i,n) for(int i=0,i##_end=(int(n));i<i##_end;i++)
#define SZ(x) (int)(x.size())
#define ALL(x) (x).begin(),(x).end()
#define MP make_pair
#define FOR_EACH(it,v) for(__typeof(v.begin()) it=v.begin(),it_end=v.end() ; it != it_end ; it++)
typedef vector<int> VI;
typedef vector<VI> VVI;

int C[1111][1111];
const int mod = 573;
int main()
{
    FOR(i,1111) FOR(j,1111){
        if(i == j || j == 0) C[i][j] = 1;
        else if(i < j) C[i][j] = 0;
        else C[i][j] = (C[i-1][j] + C[i-1][j-1]) % mod;
    }
    VI h(26);
    string s;
    cin>>s;
    FOR(i,SZ(s)) h[s[i]-'A']++;
    int all = SZ(s);
    int ans = 1;
    FOR(i,26){
        if(h[i]==0) continue;
        ans *= C[all][h[i]];
        ans %= mod;
        all -= h[i];
    }
    ans = (ans + mod - 1) % mod;
    cout<<ans<<endl;
    return 0;
}
0