結果

問題 No.2021 Not A but B
ユーザー U SU S
提出日時 2022-07-29 23:13:35
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,285 bytes
コンパイル時間 466 ms
コンパイル使用メモリ 87,072 KB
実行使用メモリ 97,532 KB
最終ジャッジ日時 2023-09-26 22:51:32
合計ジャッジ時間 5,339 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 97 ms
73,824 KB
testcase_02 AC 99 ms
73,912 KB
testcase_03 AC 108 ms
73,816 KB
testcase_04 WA -
testcase_05 AC 103 ms
73,544 KB
testcase_06 WA -
testcase_07 AC 100 ms
73,860 KB
testcase_08 WA -
testcase_09 AC 141 ms
95,424 KB
testcase_10 WA -
testcase_11 AC 142 ms
95,220 KB
testcase_12 AC 140 ms
95,172 KB
testcase_13 AC 135 ms
95,184 KB
testcase_14 AC 141 ms
95,424 KB
testcase_15 WA -
testcase_16 AC 138 ms
95,056 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 134 ms
95,676 KB
testcase_20 WA -
testcase_21 AC 110 ms
78,416 KB
testcase_22 AC 109 ms
78,440 KB
testcase_23 AC 106 ms
78,388 KB
testcase_24 AC 104 ms
78,132 KB
testcase_25 AC 111 ms
78,708 KB
testcase_26 AC 111 ms
81,580 KB
testcase_27 AC 135 ms
97,532 KB
testcase_28 AC 143 ms
97,416 KB
testcase_29 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

# import sys
# sys.setrecursionlimit(10**7)
# input = sys.stdin.readline
# import pypyjit
# pypyjit.set_param('max_unroll_recursion=-1')
def mp():return map(int,input().split())
def lmp():return list(map(int,input().split()))
def mps(A):return [tuple(map(str, input().split())) for _ in range(A)]
def stoi(LIST):return list(map(int,LIST))
def itos(LIST):return list(map(str,LIST))
def atoi(LIST): return [ord(i)-ord("a") for i in LIST]
def Atoi(LIST): return [ord(i)-ord("A") for i in LIST]
def bitA(X,A):return X & 1<<A == 1<<A
import math
import bisect
import heapq
import time
from copy import copy as cc
from copy import deepcopy as dc
from itertools import accumulate, product
from collections import Counter, defaultdict, deque
def ceil(U,V):return (U+V-1)//V
def modf1(N,MOD):return (N-1)%MOD+1
inf = int(1e18)+20
mod = int(1e9+7)
def rle(lst):
    ans = []
    cnt = 1
    ini = lst[0]
    for i in range(1, len(lst)):
        if ini == lst[i]:cnt += 1
        else:
            ans.append((ini, cnt))
            cnt = 1
            ini = lst[i]
    ans.append((ini, cnt))
    return ans

n = int(input())
s = list(input())
ans = 0
sr = rle(s)
sj = "".join(s)
for i,j in sr:
    if i == "A":
        if j == 1:ans += 1
        else:ans += j+1
if "BB" in sj:ans += 1
print(ans)
0