标签:return space || tchar tarjan for ace get ext
#include <bits/stdc++.h> using namespace std; #define INF 0x3f3f3f3f #define MAXN 1000010 #define MAXM 5010 inline int read() { int x = 0,ff = 1;char ch = getchar(); while(!isdigit(ch)) { if(ch == ‘-‘) ff = -1; ch = getchar(); } while(isdigit(ch)) { x = (x << 1) + (x << 3) + (ch ^ 48); ch = getchar(); } return x * ff; } int n,m,ti = 0,dfn[MAXN],low[MAXN],cut[MAXN]; int lin[MAXN],tot = 0; struct edge { int y,next; }e[MAXN]; inline void add(int xx,int yy) { e[++tot].y = yy; e[tot].next = lin[xx]; lin[xx] = tot; } void Tarjan(int x) { dfn[x] = low[x] = ++ti; int son = 0; for(int i = lin[x],y;i;i = e[i].next) { if(!dfn[y = e[i].y]) { Tarjan(y); low[x] = min(low[x],low[y]); if(low[y] >= dfn[x]) { son++; if(x ^ 1 || son >= 2) cut[x] = true; } } else low[x] = min(low[x],dfn[y]); } } int main() { n = read(); m = read(); for(int i = 1;i <= m;++i) { int x,y; x = read(); y = read(); add(x,y); add(y,x); } Tarjan(1); system("PAUSE"); return 0; }
标签:return space || tchar tarjan for ace get ext
原文地址:https://www.cnblogs.com/AK-ls/p/10388601.html