結果
| 問題 | No.2021 Not A but B |
| コンテスト | |
| ユーザー |
rururun
|
| 提出日時 | 2024-11-10 12:14:16 |
| 言語 | Swift (6.2.4) |
| 結果 |
AC
|
| 実行時間 | 23 ms / 2,000 ms |
| コード長 | 284 bytes |
| 記録 | |
| コンパイル時間 | 11,087 ms |
| コンパイル使用メモリ | 139,692 KB |
| 実行使用メモリ | 13,160 KB |
| 最終ジャッジ日時 | 2026-05-09 12:48:45 |
| 合計ジャッジ時間 | 13,599 ms |
|
ジャッジサーバーID (参考情報) |
judge2_1 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 26 |
ソースコード
let n = Int(readLine()!)!
var s = readLine()!.map{String($0)}
s.append("A")
var cnt = 0, f = true
for i in 0...(n-2){
if s[i] == "A"{
cnt += 1
}else{
if f && s[i+1] == "B"{
cnt += 1
f = false
}else if s[i+1] == "A" && s[i+2] == "A"{
cnt += 1
}
}
}
print(cnt)
rururun