hack
查看原帖
hack
482660
konyakest楼主2023/9/3 15:50

今天发现以前一份笔误的代码竟然过了

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++;//此处笔误,应为 child>=2
}

hack:

in:

4 3
1 2
1 3
1 4

out:

1
1

wrong ans:

0
2023/9/3 15:50
加载中...