結果

問題 No.2240 WAC
ユーザー kuro_B
提出日時 2023-05-11 19:33:12
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 1,928 bytes
コンパイル時間 323 ms
コンパイル使用メモリ 82,364 KB
実行使用メモリ 270,944 KB
最終ジャッジ日時 2024-11-27 16:05:33
合計ジャッジ時間 30,766 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 36 TLE * 7
権限があれば一括ダウンロードができます

ソースコード

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-testpypy
if __file__=='prog.py':
sys.setrecursionlimit(10**5)
else:
sys.setrecursionlimit(10**6)
def lcm(a, b): return a * b // gcd(a, b)
#3/NMO(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')
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0