結果

問題 No.171 スワップ文字列(Med)
ユーザー purple_jwlpurple_jwl
提出日時 2015-03-23 00:41:10
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 10 ms / 1,000 ms
コード長 967 bytes
コンパイル時間 1,235 ms
コンパイル使用メモリ 150,480 KB
実行使用メモリ 10,984 KB
最終ジャッジ日時 2023-09-11 09:41:51
合計ジャッジ時間 2,018 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 4 ms
5,724 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 4 ms
4,884 KB
testcase_06 AC 6 ms
7,568 KB
testcase_07 AC 9 ms
10,224 KB
testcase_08 AC 9 ms
10,980 KB
testcase_09 AC 10 ms
10,984 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

#define REP(i, x, n) for(int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define F first
#define S second
#define mp make_pair

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

int main() {
  // ios_base::sync_with_stdio(false);
  string S;
  vector<int> cnt(26, 0);
  cin >> S;
  int n = S.size();
  rep(i, n) {
    cnt[S[i]- 'A']++;
  }

  const int mod = 573;
  
  vector<vector<ll>> nCk(n + 1, vector<ll>(n + 1, 0));
  nCk[0][0] = 1;
  rep(i, n) REP(j, 0, i + 1) {
    nCk[i + 1][j] += nCk[i][j];
    nCk[i + 1][j] %= mod;
    nCk[i + 1][j + 1] += nCk[i][j];
    nCk[i + 1][j + 1] %= mod;
  }

  ll ans = 1;
  rep(i, 26) {
    if(cnt[i]) {
      ans *= nCk[n][cnt[i]];
      ans %= mod;
      n -= cnt[i];
    }
  }
  
  ans = (ans - 1 + mod) % mod;

  cout << ans << endl;
  
  return 0;
}
0