結果

問題 No.2240 WAC
ユーザー kuro_Bkuro_B
提出日時 2023-05-11 19:33:12
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 1,928 bytes
コンパイル時間 325 ms
コンパイル使用メモリ 82,816 KB
実行使用メモリ 271,140 KB
最終ジャッジ日時 2024-05-05 16:50:12
合計ジャッジ時間 6,620 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 132 ms
87,808 KB
testcase_01 AC 136 ms
82,560 KB
testcase_02 AC 138 ms
82,560 KB
testcase_03 AC 131 ms
82,432 KB
testcase_04 AC 130 ms
82,432 KB
testcase_05 AC 149 ms
82,560 KB
testcase_06 AC 147 ms
82,816 KB
testcase_07 AC 152 ms
82,816 KB
testcase_08 AC 150 ms
82,560 KB
testcase_09 AC 151 ms
82,560 KB
testcase_10 TLE -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

###スニペット始まり###
import sys, re
from copy import copy, deepcopy
from math import ceil, floor, sqrt,factorial, gcd, pi, degrees, radians, sin, asin, cos, acos, tan, atan2
from statistics import mean, median
from collections import Counter, deque, defaultdict
from heapq import heapify, heappop, heappush
from itertools import permutations, accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left, bisect_right
from functools import reduce, lru_cache
from string import ascii_uppercase, ascii_lowercase
from decimal import Decimal, ROUND_HALF_UP #四捨五入用

def input(): return sys.stdin.readline().rstrip('\n')
#easy-testのpypyでは再帰数を下げる。
if __file__=='prog.py':
    sys.setrecursionlimit(10**5)
else:
    sys.setrecursionlimit(10**6)

def lcm(a, b): return a * b // gcd(a, b)

#3つ以上の最大公約数/最小公倍数。Nを要素数、Mを数値の大きさとして、O(NlogM)
def gcd_v2(l: list): return reduce(gcd, l)
def lcm_v2(l: list): return reduce(lcm, l)

#nPk
def nPk(n, k): return factorial(n) // factorial(n - k)

#逆元
def modinv(a, mod=10**9+7): return pow(a, mod-2, mod)
INF = float('inf')
MOD = 10 ** 9 + 7
###スニペット終わり###

N, M=map(int, input().split())
L=2*N+2*M
S=input()

A_idx=deque()
for i in range(L):
    if S[L-1-i]=='A':
        A_idx.append(L-1-i)
    elif S[L-1-i]=='W':
        if not A_idx:
            print('No')
            exit()
        else:
            A_idx.popleft()

A_idx=set(A_idx)
res=''

for i,s in enumerate(S):
    if s=='A' and i in A_idx:
        res+=s
    elif s=='C':
        res+=s

#あとは尺取り

q = deque()
A_cnt=0
C_cnt=0
for c in res:
    q.append(c) 
    if c=='A':
        A_cnt+=1
    else:
        C_cnt+=1
    
    if A_cnt<C_cnt:
        print('No')
        exit()
    else:
        if c=='C':
            A_cnt-=1
            C_cnt-=1
print('Yes')
0