結果

問題 No.171 スワップ文字列(Med)
ユーザー yuruhiyayuruhiya
提出日時 2020-05-10 10:26:22
言語 Crystal
(1.11.2)
結果
WA  
実行時間 -
コード長 437 bytes
コンパイル時間 17,145 ms
コンパイル使用メモリ 254,576 KB
実行使用メモリ 8,976 KB
最終ジャッジ日時 2023-09-13 10:33:47
合計ジャッジ時間 18,354 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
4,564 KB
testcase_01 AC 2 ms
4,432 KB
testcase_02 AC 8 ms
6,964 KB
testcase_03 AC 2 ms
4,440 KB
testcase_04 AC 2 ms
4,468 KB
testcase_05 WA -
testcase_06 AC 12 ms
7,540 KB
testcase_07 AC 16 ms
8,548 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 3 ms
4,408 KB
testcase_11 AC 2 ms
4,384 KB
testcase_12 AC 3 ms
4,432 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

MOD = 573

def calc_combination(n)
  res = Array.new(n + 1) { Array.new(n + 1, 1) }
  2.upto(n) do |i|
    1.upto(i - 1) do |j|
      res[i][j] = res[i-1][j-1] + res[i-1][j] % MOD
      res[j][i] = res[i][j]
    end
  end
  res
end

s = read_line
comb = calc_combination(s.size)
cnt = Array.new(26, 0)
s.each_char do |c|
  cnt[c - 'A'] += 1
end

m = s.size
ans = 1
cnt.each do |i|
  ans = ans * comb[m][i] % MOD
  m -= i
end
puts ans - 1
0