結果

問題 No.171 スワップ文字列(Med)
ユーザー kk
提出日時 2021-03-01 18:03:51
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 5 ms / 1,000 ms
コード長 608 bytes
コンパイル時間 2,134 ms
コンパイル使用メモリ 196,684 KB
実行使用メモリ 7,700 KB
最終ジャッジ日時 2024-04-14 03:45:47
合計ジャッジ時間 2,991 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
7,644 KB
testcase_01 AC 4 ms
7,604 KB
testcase_02 AC 5 ms
7,588 KB
testcase_03 AC 4 ms
7,544 KB
testcase_04 AC 4 ms
7,680 KB
testcase_05 AC 5 ms
7,620 KB
testcase_06 AC 4 ms
7,648 KB
testcase_07 AC 4 ms
7,700 KB
testcase_08 AC 4 ms
7,688 KB
testcase_09 AC 4 ms
7,616 KB
testcase_10 AC 4 ms
7,544 KB
testcase_11 AC 4 ms
7,568 KB
testcase_12 AC 4 ms
7,552 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

const int MOD = 573;
int comb[1024][1024];

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  for (int i = 0; i < 1024; i++) {
    comb[i][0] = comb[i][i] = 1;
    for (int j = 1; j < i; j++) {
      comb[i][j] = (comb[i-1][j-1] + comb[i-1][j]) % MOD;
    }
  }

  string s;
  cin >> s;
  
  long long ret = 1;
  long long acc = 0;

  for (char c = 'A'; c <= 'Z'; c++) {
    int x = count(s.begin(), s.end(), c);
    ret *= comb[acc + x][x];
    ret %= MOD;
    acc += x;
  }

  ret = (ret - 1 + MOD) % MOD;
  cout << ret << endl;
  
  return 0;
}
0