#24826: 請教各位這要怎麼優化才不會TLE (Python)


hsugoya@gmail.com (Мигает cf4?)


這一題我卡很久但一直都TLE

拜託高手解惑

 

#0: 5% TLE (3s)

Killed

 

List=[]

n,q=map(int,input().split())

List=list(input().split())

for i in range(q):

    T=input()

    if T[0]=='1':

        o,x,v=T.split()

        x=int(x)

        List[x-1]=v

    if T[0]=='2':

        o,L,R,k=T.split()

        L=int(L)

        R=int(R)

        k=int(k)

        Q=int(''.join(List[L-1:R]))

        if Q%k==0:

            print("YES")

        if Q%k!=0:

            print("NO")

#24827: Re:請教各位這要怎麼優化才不會TLE (Python)


asnewchien@gmail.com (david)


看一下 cpp 最快要 0.2 s

python 很難在 3s 內

#24830: Re:請教各位這要怎麼優化才不會TLE (Python)


hsugoya@gmail.com (Мигает cf4?)


看一下 cpp 最快要 0.2 s

python 很難在 3s 內


感謝