結果

問題 No.171 スワップ文字列(Med)
ユーザー TwizzTwizz
提出日時 2017-05-17 10:18:09
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 630 bytes
コンパイル時間 1,316 ms
コンパイル使用メモリ 160,656 KB
実行使用メモリ 11,556 KB
最終ジャッジ日時 2023-10-17 14:41:00
合計ジャッジ時間 2,020 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 9 ms
11,552 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 9 ms
11,552 KB
testcase_12 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include"bits/stdc++.h"

//#include<bits/stdc++.h>
using namespace std;
#define print(x) cout<<x<<endl;
#define rep(i,a,b) for(int i=a;i<b;i++)
typedef long long ll;
const ll mod = 537;

string s;

int main() {
	cin >> s;

	ll count[26] = {};
	ll n= s.size();
	ll c[1005][1005] = {};

	rep(i, 1, 1002) {
		rep(j, 0, i+1) {
			c[i][j] = (j == 0 || j == 1) ? 1 : (c[i - 1][j - 1] + c[i - 1][j]) % mod;
		}
	}

	rep(i, 0, n) {
		count[s[i] - 'A']++;
	}
	
	ll ret = 1;

	rep(i, 0, 26) {
		if (count[i] > 1) {
			ret = ret*c[n][count[i]] % mod;
			n -= count[i];
		}
	}
	
	if (ret == 0) { print(0); }
	else print(ret - 1);
	return 0;
}
0