标签:reg put style min while max turn dep register
int n; int h[MAX_N], nxt[MAX_N * MAX_N], to[MAX_N * MAX_N], tot; int c[MAX_N], cnt; int dfn[MAX_N], low[MAX_N]; int st[MAX_N], top; int vis[MAX_N]; int dep; void Tarjan(int x) { dfn[x] = low[x] = ++dep; st[++top] = x; vis[x] = 1; for(register int i = h[x]; i; i = nxt[i]) { if(!dfn[to[i]]) Tarjan(to[i]); else if(vis[to[i]] ^ 1) continue; low[x] = min(low[x], low[to[i]]); } if(dfn[x] == low[x]) { c[x] = ++cnt; vis[x] = 0; while(st[top] != x) { c[st[top]] = cnt; vis[st[top--]] = 0; } --top; } return; } int main() { // input..... for(register int i = 1; i <= n; ++i) { if(c[i]) continue; Tarjan(i); } // program..... return 0; }
标签:reg put style min while max turn dep register
原文地址:https://www.cnblogs.com/kcn999/p/10544970.html