class segtree: def __init__(self,n): self.size=1 while self.size1: x//=2 self.dat[x]=(self.dat[2*x]+self.dat[2*x+1]) def querry(self,u,v): u+=self.size v+=self.size score=0 while u0: Z.update(x-1,dist[A[x]][A[x-1]]) if x