結果

問題 No.2021 Not A but B
ユーザー EguyEguy
提出日時 2022-07-29 21:43:46
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 98 ms / 2,000 ms
コード長 434 bytes
コンパイル時間 311 ms
コンパイル使用メモリ 86,920 KB
実行使用メモリ 79,496 KB
最終ジャッジ日時 2023-09-26 20:15:40
合計ジャッジ時間 4,236 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,088 KB
testcase_01 AC 73 ms
71,448 KB
testcase_02 AC 72 ms
71,200 KB
testcase_03 AC 77 ms
71,128 KB
testcase_04 AC 73 ms
71,236 KB
testcase_05 AC 72 ms
71,316 KB
testcase_06 AC 74 ms
71,244 KB
testcase_07 AC 73 ms
71,216 KB
testcase_08 AC 96 ms
79,036 KB
testcase_09 AC 97 ms
79,352 KB
testcase_10 AC 96 ms
79,380 KB
testcase_11 AC 95 ms
79,200 KB
testcase_12 AC 96 ms
79,232 KB
testcase_13 AC 96 ms
79,260 KB
testcase_14 AC 95 ms
79,368 KB
testcase_15 AC 93 ms
79,368 KB
testcase_16 AC 93 ms
79,236 KB
testcase_17 AC 96 ms
79,264 KB
testcase_18 AC 98 ms
79,340 KB
testcase_19 AC 93 ms
79,376 KB
testcase_20 AC 93 ms
79,064 KB
testcase_21 AC 86 ms
75,860 KB
testcase_22 AC 84 ms
75,796 KB
testcase_23 AC 88 ms
75,948 KB
testcase_24 AC 84 ms
75,820 KB
testcase_25 AC 87 ms
75,896 KB
testcase_26 AC 90 ms
79,496 KB
testcase_27 AC 89 ms
79,228 KB
testcase_28 AC 90 ms
79,168 KB
testcase_29 AC 88 ms
79,284 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys, math
sys.setrecursionlimit(1000000)
INF = 1 << 100
#mod = 1000000007
mod = 998244353
input = lambda: sys.stdin.readline().rstrip()
li = lambda: list(map(int, input().split()))

N = int(input())
S = list(input())
ans = N-1

for i in range(1, N-1):
    if S[i-1] == S[i+1] == 'B' and S[i] == 'A':
        ans -= 1

flg = 0
for i in range(N-1):
    if S[i] == S[i+1] == 'B':
        ans -= 1
        flg = 1

print(ans + flg)
0