結果

問題 No.171 スワップ文字列(Med)
ユーザー vain0vain0
提出日時 2015-05-24 23:47:02
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 900 bytes
コンパイル時間 483 ms
コンパイル使用メモリ 70,548 KB
実行使用メモリ 8,760 KB
最終ジャッジ日時 2023-09-20 12:50:44
合計ジャッジ時間 3,252 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <cmath>
#include <map>
#include <string>
#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;
#define repi(_I, _B, _E) for(int _I = (_B); (_I) < (_E); ++ (_I))
#define rep(_I, _N) for(int _I = 0; (_I) < (_N); ++ (_I))

static int const MOD = 573;

int combi(int a, int b) {
	if ( a < b || b < 0 ) return 0;
	if ( a == b || a == 0 || b == 0 ) return 1;
	if ( b == 1 ) return a;
	
	static int t[1000 + 1][1000+1];
	return ( t[a][b] )
		? t[a][b]
		: (t[a][b] = t[a][a - b] = (combi(a - 1, b) + combi(a - 1, b - 1)) % MOD);
}

int cnts['Z' - 'A' + 1];

int main() {
	string s;
	cin >> s;
	int n = 0;
	rep(i, s.size()) {
		char c = s[i];
		if ( 'A' <= c && c <= 'Z' ) {
			cnts[c - 'A'] ++;
			n++;
		}
	}

	int m = n;
	int res = 1;
	rep(i, 26) {
		int r = cnts[i];
		res = (res * combi(m, r)) % MOD;
		m -= r;
	}
	cout << (res + MOD - 1) % MOD << endl;
	return 0;
}
0