結果

問題 No.2021 Not A but B
ユーザー vwxyzvwxyz
提出日時 2022-09-06 14:15:37
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 189 ms / 2,000 ms
コード長 351 bytes
コンパイル時間 136 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 11,264 KB
最終ジャッジ日時 2024-05-01 11:34:17
合計ジャッジ時間 3,908 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 25 ms
10,624 KB
testcase_01 AC 25 ms
10,624 KB
testcase_02 AC 24 ms
10,752 KB
testcase_03 AC 24 ms
10,752 KB
testcase_04 AC 27 ms
10,624 KB
testcase_05 AC 27 ms
10,624 KB
testcase_06 AC 27 ms
10,624 KB
testcase_07 AC 27 ms
10,752 KB
testcase_08 AC 138 ms
11,136 KB
testcase_09 AC 137 ms
11,008 KB
testcase_10 AC 147 ms
11,136 KB
testcase_11 AC 142 ms
11,136 KB
testcase_12 AC 142 ms
11,008 KB
testcase_13 AC 129 ms
11,136 KB
testcase_14 AC 131 ms
11,008 KB
testcase_15 AC 129 ms
11,136 KB
testcase_16 AC 135 ms
11,008 KB
testcase_17 AC 144 ms
11,264 KB
testcase_18 AC 143 ms
11,264 KB
testcase_19 AC 147 ms
11,136 KB
testcase_20 AC 142 ms
11,136 KB
testcase_21 AC 31 ms
10,752 KB
testcase_22 AC 28 ms
10,624 KB
testcase_23 AC 28 ms
10,624 KB
testcase_24 AC 26 ms
10,624 KB
testcase_25 AC 27 ms
10,624 KB
testcase_26 AC 105 ms
11,136 KB
testcase_27 AC 146 ms
11,136 KB
testcase_28 AC 146 ms
11,136 KB
testcase_29 AC 189 ms
11,264 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict
import sys
readline=sys.stdin.readline
write=sys.stdout.write

N=int(readline())
S=readline().rstrip()
ans=0
if "BB" in S:
    ans+=1
for n in range(N-1):
    if S[n:n+2]=="AA":
        ans+=1
for n in range(N):
    if S[n]=="A":
        if n and S[n-1]=="B" or n!=N-1 and S[n+1]=="B":
            ans+=1
print(ans)
0