题解看不懂qwq
查看原帖
题解看不懂qwq
519187
Nodlek楼主2021/6/8 20:35

在这个题解

cost[i][j]cost[i][j] 为节点 i 向上跳 2j2^j 步到达的节点的边权和,现在正 dfs 到节点 now 。

1.为什么有:

cost[now][i]=cost[fa[now][i1]][i1]+cost[now][i1];cost[now][i]=cost[fa[now][i-1]][i-1]+cost[now][i-1];

2.LCA函数里,为什么判断条件写成 if(depth[y]-(1<<i)>=depth[x]) ,即 ifif depth[y]2idepth[x]depth[y]-2^i \geq depth[x] ???

苦思无果,求路过dalao瞅瞅

2021/6/8 20:35
加载中...