版本比较
模版:强联通分量——暨 Tarjan 有向图缩点
正文
增加 7 行删除 7 行
61 行未改动626364656666676869707071727273747576767778798016 行未改动97989910010110110210310410510610710810911011011111211311418 行未改动13313413513613713713813914014114 行未改动61 行未改动 for (int i=1;i<=n;i++) mep.W[i]=read(); for (int i=1;i<=m;i++) u=read(),v=read(),mep.add(u,v);
for (int i=1;i<=n;i++) if (!SCC.dfn[i]) SCC.dfs(i);
solve();
for (int i=1;i<=cnt;i++) ans=max(ans,f[i]); printf ("%d\n",ans);
return 0;}
inline int read()16 行未改动 tot++; dfn[w]=tot; low[w]=tot; q[++top]=w;
for (int i=mep.h[w],j;i!=0;i=mep.b[i].ne) { j=mep.b[i].v; if (!dfn[j]) dfs(j); if (!scc[j]) low[w]=min(low[w],low[j]); }
if (low[w]==dfn[w]) update(w);}
18 行未改动 Smep.add(scc[w],scc[j]); } Smep.W[scc[w]]+=mep.W[w]; }
tp=1,en=0; for (int i=1;i<=cnt;i++) if (!Smep.in[i]) q[++en]=i,f[i]=Smep.W[i];14 行未改动