1
# Runtime: 1682 ms (Top 100.0%) | Memory: 18.40 MB (Top 71.7%)5
def minimumScore(self, nums: List[int], edges: List[List[int]]) -> int:7
graph = [[] for _ in range(n)]15
tin[u] = (t := t + 1) # time to enter20
tout[u] = t # time to exit30
for v in range(u + 1, n):32
tin[v] <= tin[u] and tout[v] >= tout[u]33
): # enter earlier & exit later == parent35
vv = score[v] ^ score[u]36
xx = score[0] ^ score[v]37
elif tin[v] >= tin[u] and tout[v] <= tout[u]:38
uu = score[u] ^ score[v]40
xx = score[0] ^ score[u]44
xx = score[0] ^ score[u] ^ score[v]45
ans = min(ans, max(uu, vv, xx) - min(uu, vv, xx))