結果
問題 |
No.2021 Not A but B
|
ユーザー |
![]() |
提出日時 | 2022-09-06 14:15:37 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 197 ms / 2,000 ms |
コード長 | 351 bytes |
コンパイル時間 | 83 ms |
コンパイル使用メモリ | 12,544 KB |
実行使用メモリ | 11,136 KB |
最終ジャッジ日時 | 2024-11-21 15:36:14 |
合計ジャッジ時間 | 4,063 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 26 |
ソースコード
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)