結果

問題 No.2419 MMA文字列2
ユーザー simansiman
提出日時 2023-08-13 17:22:06
言語 Ruby
(3.3.0)
結果
TLE  
実行時間 -
コード長 256 bytes
コンパイル時間 216 ms
コンパイル使用メモリ 11,248 KB
実行使用メモリ 15,920 KB
最終ジャッジ日時 2023-08-13 17:22:35
合計ジャッジ時間 27,723 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 82 ms
15,152 KB
testcase_01 AC 80 ms
15,248 KB
testcase_02 AC 92 ms
15,132 KB
testcase_03 AC 84 ms
15,116 KB
testcase_04 AC 80 ms
15,300 KB
testcase_05 AC 79 ms
15,144 KB
testcase_06 AC 84 ms
15,244 KB
testcase_07 AC 80 ms
15,148 KB
testcase_08 AC 81 ms
15,268 KB
testcase_09 AC 78 ms
15,112 KB
testcase_10 AC 83 ms
15,240 KB
testcase_11 AC 82 ms
15,116 KB
testcase_12 AC 532 ms
15,332 KB
testcase_13 AC 150 ms
15,232 KB
testcase_14 AC 948 ms
15,328 KB
testcase_15 AC 610 ms
15,444 KB
testcase_16 AC 1,016 ms
15,584 KB
testcase_17 AC 350 ms
15,212 KB
testcase_18 AC 1,050 ms
15,592 KB
testcase_19 AC 1,078 ms
15,464 KB
testcase_20 AC 386 ms
15,460 KB
testcase_21 AC 296 ms
15,444 KB
testcase_22 AC 1,942 ms
15,760 KB
testcase_23 AC 1,936 ms
15,660 KB
testcase_24 AC 1,921 ms
15,828 KB
testcase_25 AC 1,921 ms
15,760 KB
testcase_26 AC 298 ms
15,336 KB
testcase_27 AC 1,906 ms
15,772 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