結果

問題 No.171 スワップ文字列(Med)
ユーザー 夜
提出日時 2020-11-04 06:00:59
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 6 ms / 1,000 ms
コード長 864 bytes
コンパイル時間 721 ms
コンパイル使用メモリ 91,972 KB
実行使用メモリ 10,652 KB
最終ジャッジ日時 2023-09-29 15:30:52
合計ジャッジ時間 1,497 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
10,620 KB
testcase_01 AC 5 ms
10,588 KB
testcase_02 AC 5 ms
10,588 KB
testcase_03 AC 5 ms
10,580 KB
testcase_04 AC 5 ms
10,568 KB
testcase_05 AC 5 ms
10,632 KB
testcase_06 AC 6 ms
10,584 KB
testcase_07 AC 5 ms
10,652 KB
testcase_08 AC 5 ms
10,584 KB
testcase_09 AC 5 ms
10,644 KB
testcase_10 AC 5 ms
10,564 KB
testcase_11 AC 5 ms
10,556 KB
testcase_12 AC 5 ms
10,584 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <algorithm>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
long long co[30] = {};
long long a[1010][1010];
int main() {
	string s;
	cin >> s;
	long long n = s.size();
	for (int i = 0; i < n; i++) {
		co[int(s[i] - 'A')]++;
	}
	long long ans = 1;
	for (int i = 0; i < 1010; i++) {
		for (int j = 0; j <= i; j++) {
			if (j == 0) {
				a[i][j] = 1;
			}
			else {
				a[i][j] = (a[i - 1][j] + a[i - 1][j - 1]) % 573;
			}
		}
	}
	for (int i = 0; i < 26; i++) {
		ans *= a[n][co[i]];
		n -= co[i];
		ans %= 573;
	}
	ans--;
	if (ans < 0) {
		ans += 573;
	}
	cout << ans << endl;
}
0