結果

問題 No.2419 MMA文字列2
ユーザー simansiman
提出日時 2023-08-13 17:22:06
言語 Ruby
(3.3.0)
結果
TLE  
実行時間 -
コード長 256 bytes
コンパイル時間 135 ms
コンパイル使用メモリ 7,552 KB
実行使用メモリ 12,800 KB
最終ジャッジ日時 2024-05-01 10:04:30
合計ジャッジ時間 27,837 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 91 ms
12,288 KB
testcase_01 AC 87 ms
12,160 KB
testcase_02 AC 85 ms
12,416 KB
testcase_03 AC 93 ms
12,160 KB
testcase_04 AC 95 ms
12,288 KB
testcase_05 AC 88 ms
12,160 KB
testcase_06 AC 90 ms
12,288 KB
testcase_07 AC 90 ms
12,288 KB
testcase_08 AC 89 ms
12,160 KB
testcase_09 AC 89 ms
12,416 KB
testcase_10 AC 89 ms
12,160 KB
testcase_11 AC 91 ms
12,288 KB
testcase_12 AC 567 ms
12,288 KB
testcase_13 AC 165 ms
12,416 KB
testcase_14 AC 984 ms
12,416 KB
testcase_15 AC 637 ms
12,288 KB
testcase_16 AC 1,018 ms
12,544 KB
testcase_17 AC 364 ms
12,416 KB
testcase_18 AC 1,068 ms
12,416 KB
testcase_19 AC 1,094 ms
12,416 KB
testcase_20 AC 412 ms
12,288 KB
testcase_21 AC 310 ms
12,288 KB
testcase_22 AC 1,998 ms
12,544 KB
testcase_23 TLE -
testcase_24 AC 1,995 ms
12,544 KB
testcase_25 AC 1,997 ms
12,800 KB
testcase_26 AC 317 ms
12,416 KB
testcase_27 AC 1,928 ms
12,672 KB
testcase_28 TLE -
testcase_29 TLE -
testcase_30 TLE -
testcase_31 TLE -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

S = gets.chomp
counter = Array.new(26, 0)

ans = 0

S.each_char do |s|
  ('A'..'Z').each do |c|
    next if s == c
    cnt = counter[c.ord - 'A'.ord]
    next if cnt <= 1

    ans += cnt * (cnt - 1) / 2
  end

  counter[s.ord - 'A'.ord] += 1
end

puts ans
0