結果

問題 No.171 スワップ文字列(Med)
ユーザー IL_mstaIL_msta
提出日時 2015-07-09 06:31:17
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,203 bytes
コンパイル時間 678 ms
コンパイル使用メモリ 86,812 KB
実行使用メモリ 10,064 KB
最終ジャッジ日時 2023-09-22 09:40:06
合計ジャッジ時間 3,446 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
8,756 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 5 ms
5,940 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 WA -
testcase_06 TLE -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>

#include <algorithm>
#include <cmath>

#include <string>
#include <array>
#include <list>
#include <queue>
#include <vector>
#include <complex>
#include <set>

/////////
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define P(p) cout<<(p)<<endl;
/////////
typedef long long LL;
typedef long double LD;
/////////
using namespace::std;
/////////
const LL mod = 573;
LL cdp[1001][501];
LL ccc(int n,int k){
	if(k<0){
		return 0;
	}
	else if( n < k){
		return 0;
	}
	//0<=k<=n
	
	k = min(k,n-k);

	if(k==0){
		return 1;
	}
	else if( k == 1){
		return n;
	}
	else if( cdp[n][k] != 0){
		return cdp[n][k];
	}

	////////
	LL ans = 0;
	ans = ( ccc(n-1,k-1) + ccc(n-1,k) )%mod;
	cdp[n][k] = ans;
	return ans;
}

int main(void){
    std::cin.tie(0); 
    std::ios::sync_with_stdio(false);
    std::cout << std::fixed;//
    cout << setprecision(10);//

	string str;
	cin>>str;
	int N = str.size();
	int s[26];
	rep(i,26)s[i]=0;
	rep(i,N){
		++s[ str[i] - 'A' ];
	}
	sort(s,s+26);
	LL ans=1;
	int nokori = N;
	rep(i,26){
		ans *= ccc( nokori,s[i] );
		ans %= mod;//mod
		nokori -= s[i];
	}
	P(ans-1);
    return 0;
}
0