結果

問題 No.171 スワップ文字列(Med)
ユーザー 古寺いろは古寺いろは
提出日時 2015-03-22 23:36:07
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 5 ms / 1,000 ms
コード長 689 bytes
コンパイル時間 519 ms
コンパイル使用メモリ 67,620 KB
実行使用メモリ 7,400 KB
最終ジャッジ日時 2023-09-11 09:33:52
合計ジャッジ時間 1,326 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
7,244 KB
testcase_01 AC 5 ms
7,312 KB
testcase_02 AC 5 ms
7,400 KB
testcase_03 AC 5 ms
7,264 KB
testcase_04 AC 5 ms
7,340 KB
testcase_05 AC 5 ms
7,316 KB
testcase_06 AC 5 ms
7,332 KB
testcase_07 AC 4 ms
7,264 KB
testcase_08 AC 5 ms
7,268 KB
testcase_09 AC 5 ms
7,320 KB
testcase_10 AC 5 ms
7,308 KB
testcase_11 AC 5 ms
7,316 KB
testcase_12 AC 5 ms
7,312 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include<map>

#define mod 573

using namespace std;

int dp[1001][1001];

void settingC(){
	for (int i = 0; i < 1001; i++)
	{
		dp[i][0] = 1;
		for (int j = 1; j <= i; j++)
		{
			dp[i][j] = dp[i - 1][j - 1] + dp[i - 1][j];
			dp[i][j] %= mod;
		}
	}
}

int main(int argc, char* argv[]) {
	string S;
	cin >> S;
	map<char, int> m;

	settingC();

	for (int i = 0; i < S.size(); i++)
	{
		m[S[i]]++;
	}

	int remain = S.size();
	int ans = 1;

	map<char, int>::iterator it = m.begin();
	while (it != m.end())
	{
		ans *= dp[remain][(*it).second];
		ans %= mod;
		remain -= (*it).second;
		++it;
	}

	ans += mod - 1;
	ans %= mod;
	cout << ans << endl;
}

0