| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 
 | struct Graph{static const int maxn=1e5+5, maxm=3e5+5;
 struct star{int v,nex;}edge[maxm<<1];
 int head[maxn],cnt;
 void ini(int n){
 for(int i=0;i<=n;i++) head[i]=-1;
 cnt=-1;
 }
 void add_edge(int u,int v){
 edge[++cnt]=star{v,head[u]};
 head[u]=cnt;
 edge[++cnt]=star{u,head[v]};
 head[v]=cnt;
 }
 };
 
 struct Tarjan:Graph{
 struct Bridge{int u,v;}bridge[maxn];
 int dfn[maxn],low[maxn],belong[maxn],vis[maxn],sta[maxn],sta_,nums,bridge_;
 void ini(int n){
 for(int i=0;i<=n;i++) vis[i]=0;
 bridge_=0;
 nums=0;
 Graph::ini(n);
 }
 void tarjan(int u,int father,int&step){
 low[u]=dfn[u]=++step;
 sta[++sta_]=u;
 vis[u]=1;
 bool firsttimes=true;
 for(int i=head[u];~i;i=edge[i].nex){
 int v=edge[i].v;
 if(v==father&&firsttimes) {
 firsttimes=false;
 continue;
 }
 if(vis[v]==1) low[u]=min(low[u],dfn[v]);
 else {
 tarjan(v,u,step);
 low[u]=min(low[u],low[v]);
 if(low[v]>dfn[u]) bridge[++bridge_]=Bridge{u,v};
 }
 }
 if(low[u]==dfn[u]){
 while(sta[sta_]!=u) belong[sta[sta_--]]=nums+1;
 belong[sta[sta_--]]=++nums;
 }
 }
 }graph;
 
 |