結果
| 問題 |
No.171 スワップ文字列(Med)
|
| コンテスト | |
| ユーザー |
vain0
|
| 提出日時 | 2015-05-24 23:45:00 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 915 bytes |
| コンパイル時間 | 583 ms |
| コンパイル使用メモリ | 70,096 KB |
| 実行使用メモリ | 77,040 KB |
| 最終ジャッジ日時 | 2024-07-06 08:08:53 |
| 合計ジャッジ時間 | 3,269 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | -- * 3 |
| other | AC * 5 WA * 1 TLE * 1 -- * 3 |
ソースコード
#include <cmath>
#include <map>
#include <string>
#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;
#define repi(_I, _B, _E) for(int _I = (_B); (_I) < (_E); ++ (_I))
#define rep(_I, _N) for(int _I = 0; (_I) < (_N); ++ (_I))
typedef long long ull;
static ull const MOD = 573;
ull combi(ull a, ull b) {
if ( a == b || a == 0 || b == 0 ) return 1;
if ( b == 1 ) return a;
static ull t[1000 + 1][1000+1];
return ( t[a][b] )
? t[a][b]
: (t[a][b] = t[a][a - b] = ((a > 0 ? combi(a - 1, b) : 0) + (a > 0 && b > 0 ? combi(a - 1, b - 1) : 0)) % MOD);
}
int cnts['Z' - 'A' + 1];
int main() {
string s;
cin >> s;
int n = 0;
rep(i, s.size()) {
char c = s[i];
if ( 'A' <= c && c <= 'Z' ) {
cnts[c - 'A'] ++;
n++;
}
}
int m = n;
ull res = 1;
rep(i, 26) {
int r = cnts[i];
res = (res * combi(m, r)) % MOD;
m -= r;
}
cout << (res - 1) << endl;
return 0;
}
vain0