結果

問題 No.2240 WAC
ユーザー kuro_Bkuro_B
提出日時 2023-05-11 19:33:12
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 1,928 bytes
コンパイル時間 326 ms
コンパイル使用メモリ 87,212 KB
実行使用メモリ 270,940 KB
最終ジャッジ日時 2023-08-18 11:29:51
合計ジャッジ時間 8,307 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 262 ms
101,888 KB
testcase_01 AC 266 ms
94,972 KB
testcase_02 AC 263 ms
94,924 KB
testcase_03 AC 269 ms
95,104 KB
testcase_04 AC 272 ms
94,932 KB
testcase_05 AC 261 ms
94,736 KB
testcase_06 AC 266 ms
95,116 KB
testcase_07 AC 272 ms
95,016 KB
testcase_08 AC 270 ms
94,928 KB
testcase_09 AC 265 ms
94,932 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