結果

問題 No.171 スワップ文字列(Med)
ユーザー ldsybldsyb
提出日時 2017-07-19 01:48:18
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 9 ms / 1,000 ms
コード長 451 bytes
コンパイル時間 670 ms
コンパイル使用メモリ 65,524 KB
実行使用メモリ 11,392 KB
最終ジャッジ日時 2024-04-17 03:11:36
合計ジャッジ時間 1,217 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 4 ms
6,272 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 3 ms
5,376 KB
testcase_06 AC 6 ms
7,936 KB
testcase_07 AC 8 ms
10,496 KB
testcase_08 AC 9 ms
11,392 KB
testcase_09 AC 8 ms
11,392 KB
testcase_10 AC 1 ms
5,376 KB
testcase_11 AC 1 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
using namespace std;

int main(){
	string s;
	cin >> s;
	int64_t a[26]{};
	for(char c:s) a[c - 'A']++;
	int64_t n = s.size(), ans = 1, dp[n + 1][n + 1]{};
	for(int i = 0; i < n + 1; i++) dp[i][0] = 1;
	for(int i = 1; i < n + 1; i++) for(int j = 1; j < n + 1; j++) (dp[i][j] = dp[i - 1][j - 1] + dp[i - 1][j]) %= 573;
	for(int i = 0; i < 26; i++){
		(ans *= dp[n][a[i]]) %= 573;
		n -= a[i];
	}
	cout << (ans + 572) % 573 << endl;
}
0