今天发现以前一份笔误的代码竟然过了
int dfn[maxn],low[maxn],res,inde;
bool flag[maxn];
void tarjan(int u,int f){
dfn[u]=low[u]=++inde;
int child=0;
for(auto i:v[u]){
if(!dfn[i]){
tarjan(i,u);
low[u]=min(low[u],low[i]);
if(u!=f&&low[i]>=dfn[u]&&!flag[u]) flag[u]=1,res++;
child++;
}
else if(i!=f) low[u]=min(low[u],dfn[i]);
}
if(u==f&&child==2) flag[u]=1,res++;
}
hack:
in:
4 3
1 2
1 3
1 4
out:
1
1
wrong ans:
0