結果
| 問題 |
No.171 スワップ文字列(Med)
|
| コンテスト | |
| ユーザー |
vain0
|
| 提出日時 | 2015-05-24 23:47:02 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 900 bytes |
| コンパイル時間 | 560 ms |
| コンパイル使用メモリ | 70,568 KB |
| 実行使用メモリ | 13,756 KB |
| 最終ジャッジ日時 | 2024-07-06 08:08:57 |
| 合計ジャッジ時間 | 2,954 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | -- * 3 |
| other | AC * 6 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))
static int const MOD = 573;
int combi(int a, int b) {
if ( a < b || b < 0 ) return 0;
if ( a == b || a == 0 || b == 0 ) return 1;
if ( b == 1 ) return a;
static int t[1000 + 1][1000+1];
return ( t[a][b] )
? t[a][b]
: (t[a][b] = t[a][a - b] = (combi(a - 1, b) + combi(a - 1, b - 1)) % 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;
int res = 1;
rep(i, 26) {
int r = cnts[i];
res = (res * combi(m, r)) % MOD;
m -= r;
}
cout << (res + MOD - 1) % MOD << endl;
return 0;
}
vain0