結果
問題 | No.171 スワップ文字列(Med) |
ユーザー |
![]() |
提出日時 | 2015-03-23 08:13:25 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 4 ms / 1,000 ms |
コード長 | 789 bytes |
コンパイル時間 | 1,254 ms |
コンパイル使用メモリ | 165,588 KB |
実行使用メモリ | 11,368 KB |
最終ジャッジ日時 | 2024-06-29 00:22:27 |
合計ジャッジ時間 | 1,657 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 10 |
ソースコード
#include <bits/stdc++.h> #define rep(i, n) for (int (i) = 0; (i) < (int)(n); (i)++) const int dx[] = {1, 0, -1, 0}; const int dy[] = {0, 1, 0, -1}; using namespace std; typedef long long ll; const ll MOD = 573; const int MAXN = 1024; ll cmb[MAXN][MAXN]; void init() { cmb[0][0] = 1; for (int i = 1; i < MAXN; i++) { cmb[i][0] = 1; for (int j = 1; j <= i; j++) { cmb[i][j] = (cmb[i-1][j] + cmb[i-1][j-1]) % MOD; } } } int main() { init(); string s; cin >> s; int n = s.size(); map<char, int> m; for (char c : s) { m[c]++; } ll ans = 1; for (auto el : m) { ans *= cmb[n][el.second]; n -= el.second; ans %= MOD; } cout << (ans-1+MOD)%MOD << endl; return 0; }