From 91d9b32b013323a38b279f05abe4fad17122fe22 Mon Sep 17 00:00:00 2001 From: ksyx <1175143532@qq.com> Date: Tue, 5 Feb 2019 22:42:22 +0800 Subject: [PATCH] Fix Format (#947) * style: format markdown files with remark-lint * style: format markdown files with remark-lint * Fix Format * Update virtual-tree.md * Update virtual-tree.md * style: format markdown files with remark-lint * style: format markdown files with remark-lint * Update virtual-tree.md --- docs/ds/virtual-tree.md | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/docs/ds/virtual-tree.md b/docs/ds/virtual-tree.md index 4351aad8..d584012c 100644 --- a/docs/ds/virtual-tree.md +++ b/docs/ds/virtual-tree.md @@ -212,22 +212,22 @@ for (int i = 1, l; i <= k; i += 1) if (h[i] != 1) //如果1号节点是关键节点就不要重复添加 { l = lca(h[i], sta[top]); //计算当前节点与栈顶节点的LCA - if (l != - sta[top]) //如果LCA和栈顶元素不同,则说明当前节点不再当前栈所存的链上 - { - while (id[l] < id[sta[top - 1]]) //当次大节点的Dfs序大于LCA的Dfs序 - g.push(sta[top - 1], sta[top]), - top--; //把与当前节点所在的链不重合的链连接掉并且弹出 - if (id[l] > - id[sta[top - - 1]]) //如果LCA不等于次大节点(这里的大于其实和不等于没有区别) + if (l != sta[top]) { + //如果LCA和栈顶元素不同,则说明当前节点不再当前栈所存的链上 + while (id[l] < id[sta[top - 1]]) + //当次大节点的Dfs序大于LCA的Dfs序 + g.push(sta[top - 1], sta[top]), top--; + //把与当前节点所在的链不重合的链连接掉并且弹出 + if (id[l] > id[sta[top - 1]]) + //如果LCA不等于次大节点(这里的大于其实和不等于没有区别) g.head[l] = -1, g.push(l, sta[top]), sta[top] = l; //说明LCA是第一次入栈,清空其临接表,连边后弹出栈顶元素,并将LCA入栈 else - g.push(l, sta[top--]); //说明LCA就是次大节点,直接弹出栈顶元素 + g.push(l, sta[top--]); + //说明LCA就是次大节点,直接弹出栈顶元素 } - g.head[h[i]] = -1, - sta[++top] = h[i]; //当前节点必然是第一次入栈,清空临接表并入栈 + g.head[h[i]] = -1, sta[++top] = h[i]; + //当前节点必然是第一次入栈,清空临接表并入栈 } for (int i = 1; i < top; i += 1) g.push(sta[i], sta[i + 1]); //剩余的最后一条链连接一下 -- 2.11.0