对 Tarjan 算法的一些疑问

P3387 【模板】缩点

因为你的while是在执行完括号里的语句之后才判断条件的,你在过程中改变了,那么不会影响你接下来语句的执行
by Ztemily @ 2022-07-31 08:54:36


@[Napoleon_Bonaparte](/user/394729)
by Ztemily @ 2022-07-31 08:55:42


@[Ztemily](/user/352961) 啊看出来了,谢谢
by Weight_of_the_Soul @ 2022-07-31 08:58:55


不要用STL的栈,要不然你弹栈那里会写的很臭
by Ptilopsis_w @ 2022-07-31 12:47:07


如果用手写栈就会方便的多: ```cpp if(dfn[x] == low[x]) { scc_tot++; while(st[top+1] != x) { int x = st[top--]; color[x] = scc_tot; siz[scc_tot] += val[x]; vis[x] = false; } } ``` 用`st[top+1] != x`判定就不用写`break`或者把`x`单独处理了
by Ptilopsis_w @ 2022-07-31 12:50:30


@[Ptilopsis_w](/user/239167) 好的大佬
by Weight_of_the_Soul @ 2022-07-31 14:59:56


|