所以说 Python 过不了吗
查看原帖
所以说 Python 过不了吗
1220111
xiaoyang222楼主2024/3/20 18:09

感觉算法是对的吧。

t=int(input())
for i in range(t):
    n,q=[int(i) for i in input().split(' ')]
    t1,t2=input(),input()
    s1,s2=[],[]
    for j in range(n):
        s1.append(t1[j])
        s2.append(t2[j])
    cnt,l=0,[0]*n
    for j in range(n):
        if s1[j]!=s2[j]:
            cnt+=1
            l[j]=1
    if cnt==0:
        print("Yes")
    else:
        print("No")
    for j in range(q):
        qwq=input().split(' ')
        op,idx,c=int(qwq[0]),int(qwq[1])-1,qwq[2]
        if op==0:
            s1[idx]=c
        else:
            s2[idx]=c
        if s1[idx]==s2[idx]:
            if l[idx]==1:
                cnt-=1
                l[idx]=0
        else:
            if l[idx]==0:
                cnt+=1
                l[idx]=1
        if cnt==0:
            print("Yes")
        else:
            print("No")

还能卡吗

2024/3/20 18:09
加载中...