2025春招小米 and 美团的笔试....
from collections import Counter
m,n=map(int,input().split())
st1=map(str,input().split())
st2=''.join(st1)
result=[]
for i in range(n):
count=0
b,c=map(int,input().split())
a_=st2[b-1:c]
counter = Counter(a_) # 记录字典
for key,value in counter.items():
if value>2 and value%2!=0:
count+=(value-1)/2
if value%2==0:
count+=value/2
if count==(c-b+1)/2:
result.append('yes')
else:
result.append('no')
for i in result:
print(i)
全部评论

异或前缀 区间想减
你***了?
相关推荐

点赞 评论 收藏
分享
点赞 评论 收藏
分享