結果

問題 No.2021 Not A but B
ユーザー simansiman
提出日時 2022-07-30 08:34:52
言語 Ruby
(3.3.0)
結果
AC  
実行時間 455 ms / 2,000 ms
コード長 220 bytes
コンパイル時間 56 ms
コンパイル使用メモリ 11,276 KB
実行使用メモリ 34,808 KB
最終ジャッジ日時 2023-09-27 09:40:25
合計ジャッジ時間 9,241 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
15,164 KB
testcase_01 AC 71 ms
15,120 KB
testcase_02 AC 70 ms
15,312 KB
testcase_03 AC 72 ms
15,152 KB
testcase_04 AC 71 ms
15,332 KB
testcase_05 AC 73 ms
15,300 KB
testcase_06 AC 75 ms
15,072 KB
testcase_07 AC 72 ms
15,164 KB
testcase_08 AC 402 ms
26,348 KB
testcase_09 AC 395 ms
26,820 KB
testcase_10 AC 405 ms
26,872 KB
testcase_11 AC 388 ms
26,564 KB
testcase_12 AC 412 ms
26,604 KB
testcase_13 AC 409 ms
26,636 KB
testcase_14 AC 430 ms
26,592 KB
testcase_15 AC 417 ms
26,676 KB
testcase_16 AC 403 ms
26,660 KB
testcase_17 AC 406 ms
26,536 KB
testcase_18 AC 404 ms
26,500 KB
testcase_19 AC 408 ms
26,924 KB
testcase_20 AC 399 ms
26,944 KB
testcase_21 AC 87 ms
15,632 KB
testcase_22 AC 83 ms
15,488 KB
testcase_23 AC 83 ms
15,560 KB
testcase_24 AC 74 ms
15,100 KB
testcase_25 AC 83 ms
15,548 KB
testcase_26 AC 287 ms
15,620 KB
testcase_27 AC 423 ms
33,936 KB
testcase_28 AC 420 ms
33,252 KB
testcase_29 AC 455 ms
34,808 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

N = gets.to_i
S = gets.chomp

checked = Hash.new
ans = 0

0.upto(N - 2) do |i|
  s = []
  s << i if S[i] == 'A'
  s << i + 1 if S[i + 1] == 'A'

  if not checked[s]
    checked[s] = true
    ans += 1
  end
end

puts ans
0