結果

問題 No.2021 Not A but B
ユーザー EguyEguy
提出日時 2022-07-30 00:19:59
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 125 ms / 2,000 ms
コード長 444 bytes
コンパイル時間 734 ms
コンパイル使用メモリ 87,236 KB
実行使用メモリ 108,124 KB
最終ジャッジ日時 2023-09-27 00:41:07
合計ジャッジ時間 5,744 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,300 KB
testcase_01 AC 72 ms
71,404 KB
testcase_02 AC 72 ms
71,344 KB
testcase_03 AC 72 ms
71,664 KB
testcase_04 AC 73 ms
71,436 KB
testcase_05 AC 71 ms
71,540 KB
testcase_06 AC 74 ms
71,344 KB
testcase_07 AC 74 ms
71,420 KB
testcase_08 AC 110 ms
94,940 KB
testcase_09 AC 113 ms
97,440 KB
testcase_10 AC 110 ms
94,980 KB
testcase_11 AC 114 ms
95,100 KB
testcase_12 AC 114 ms
94,856 KB
testcase_13 AC 115 ms
94,956 KB
testcase_14 AC 119 ms
97,360 KB
testcase_15 AC 113 ms
94,972 KB
testcase_16 AC 116 ms
97,452 KB
testcase_17 AC 118 ms
97,316 KB
testcase_18 AC 114 ms
97,576 KB
testcase_19 AC 114 ms
97,344 KB
testcase_20 AC 109 ms
94,952 KB
testcase_21 AC 83 ms
76,364 KB
testcase_22 AC 81 ms
76,568 KB
testcase_23 AC 81 ms
76,512 KB
testcase_24 AC 75 ms
76,104 KB
testcase_25 AC 85 ms
76,408 KB
testcase_26 AC 83 ms
76,348 KB
testcase_27 AC 125 ms
108,016 KB
testcase_28 AC 123 ms
108,124 KB
testcase_29 AC 116 ms
107,672 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 = input()

st = set()
x = 0
for i in range(N-1):
    if S[i] == S[i+1] == 'A':
        st.add((i, i+1))
    elif S[i] == "A":
        st.add((i))
    elif S[i+1] == 'A':
        st.add((i+1))
    else:
        x = 1

print(len(st) + x)
0