結果
| 問題 |
No.2021 Not A but B
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-07-29 22:21:01 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 63 ms / 2,000 ms |
| コード長 | 721 bytes |
| コンパイル時間 | 1,132 ms |
| コンパイル使用メモリ | 82,364 KB |
| 実行使用メモリ | 73,432 KB |
| 最終ジャッジ日時 | 2024-07-19 15:25:27 |
| 合計ジャッジ時間 | 2,578 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 26 |
ソースコード
import sys
INF = float('inf')
#10**20,2**63,float('inf')
MOD = 10**9 + 7
MOD2 = 998244353
from collections import defaultdict
def solve():
def II(): return int(sys.stdin.readline())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LC(): return list(input())
def IC(): return [int(c) for c in input()]
def MI(): return map(int, sys.stdin.readline().split())
N = II()
S = input()
Ans = 0
BB = 0
for i in range(N-1):
if((S[i]=="A" and S[i+1]=="A") or (S[i]!=S[i+1])):
Ans += 1
elif((S[i]=="B" and S[i+1]=="B")):
BB=1
for i in range(N-2):
if(S[i:i+3]=="BAB"):
Ans-=1
print(Ans+BB)
return
solve()