結果

問題 No.2021 Not A but B
ユーザー k_o_pasturek_o_pasture
提出日時 2022-07-29 22:56:00
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 393 bytes
コンパイル時間 1,037 ms
コンパイル使用メモリ 86,876 KB
実行使用メモリ 93,316 KB
最終ジャッジ日時 2023-09-26 22:25:48
合計ジャッジ時間 4,355 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,328 KB
testcase_01 AC 71 ms
71,116 KB
testcase_02 AC 72 ms
71,560 KB
testcase_03 AC 72 ms
71,524 KB
testcase_04 AC 72 ms
71,416 KB
testcase_05 AC 72 ms
71,476 KB
testcase_06 AC 71 ms
71,608 KB
testcase_07 AC 71 ms
71,268 KB
testcase_08 AC 103 ms
90,360 KB
testcase_09 WA -
testcase_10 AC 104 ms
90,252 KB
testcase_11 AC 103 ms
88,772 KB
testcase_12 AC 102 ms
88,776 KB
testcase_13 WA -
testcase_14 AC 102 ms
90,212 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 100 ms
88,736 KB
testcase_18 AC 103 ms
90,352 KB
testcase_19 AC 102 ms
90,036 KB
testcase_20 AC 103 ms
90,216 KB
testcase_21 AC 81 ms
76,212 KB
testcase_22 AC 81 ms
76,324 KB
testcase_23 AC 82 ms
76,540 KB
testcase_24 AC 74 ms
76,272 KB
testcase_25 AC 80 ms
76,164 KB
testcase_26 AC 82 ms
79,172 KB
testcase_27 AC 100 ms
93,004 KB
testcase_28 AC 99 ms
93,316 KB
testcase_29 AC 95 ms
93,084 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
S = list(input())
if N == 2:
	print(1)
	exit()

T = []
for i in range(N-1):
	if (S[i] == 'B') & (S[i+1] == 'B'):
		pass
	else:
		T.append(S[i])
if (S[-1] == 'B') & (S[-2] == 'B'):
	T.append('B')
elif S[-1] == 'A':
	T.append('A')
# print(''.join(T))
M = len(T)
X = 0
for i in range(M-2):
	if (T[i] == 'B') & (T[i+2]=='B'):
		X += 1
ans = M - X
if N == M:
 	ans -= 1
print(ans)
0