結果

問題 No.171 スワップ文字列(Med)
ユーザー pekempeypekempey
提出日時 2015-08-18 15:34:49
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 23 ms / 1,000 ms
コード長 870 bytes
コンパイル時間 1,194 ms
コンパイル使用メモリ 145,872 KB
実行使用メモリ 36,680 KB
最終ジャッジ日時 2023-09-25 12:48:26
合計ジャッジ時間 2,495 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
36,484 KB
testcase_01 AC 15 ms
36,404 KB
testcase_02 AC 21 ms
36,680 KB
testcase_03 AC 15 ms
36,444 KB
testcase_04 AC 15 ms
36,484 KB
testcase_05 AC 17 ms
36,392 KB
testcase_06 AC 19 ms
36,520 KB
testcase_07 AC 23 ms
36,484 KB
testcase_08 AC 22 ms
36,400 KB
testcase_09 AC 18 ms
36,512 KB
testcase_10 AC 15 ms
36,416 KB
testcase_11 AC 16 ms
36,448 KB
testcase_12 AC 16 ms
36,436 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i, a) for (int i = 0; i < (a); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); i++)
#define repr(i, a) for (int i = (a) - 1; i >= 0; i--)
#define repr2(i, a, b) for (int i = (b) - 1; i >= (a); i--)
using namespace std;
typedef long long ll;
const ll inf = 1e9;
const ll mod = 573;

ll C[2020][2020];
ll dp[2020][2020]; // pos, len

int main() {
	string s;
	cin >> s;

	vector<int> f(26);
	rep (i, s.length()) f[s[i] - 'A']++;

	C[0][0] = 1;
	rep2 (i, 1, 2000) {
		C[i][0] = 1;
		rep2 (j, 1, 2000) {
			C[i][j] = C[i - 1][j - 1] + C[i - 1][j];	
			C[i][j] %= mod;
		}
	}

	dp[0][0] = 1;
	rep (i, 26) {
		rep (j, 1010) {
			rep (k, f[i] + 1) {
				dp[i + 1][j + k] += dp[i][j] * C[j + k][k];
				dp[i + 1][j + k] %= mod;
			}
		}
	}

	ll ans = dp[26][s.length()];
	ans = (ans + mod - 1) % mod;
	cout << ans << endl;

	return 0;
}
0