版子题,求割点

代码如下:

#include<iostream>
#include<algorithm>
#include<cstdio>
#include<functional>
using namespace std;
const int max_n = 110;
const int max_m = 11000;
struct edge{
    int to, next;
}E[max_m << 1];
int head[max_n];
;int cnt = 1;
void add(int from, int to) {
    E[cnt].to = to;E[cnt].next = head[from];
    head[from] = cnt++;
}

bool is[max_n];int tot = 0;
int dfn[max_n], low[max_n];
void tarjan(int u,int fa) {
    int child = 0;
    dfn[u] = low[u] = ++tot;
    for (int i = head[u];i;i = E[i].next) {
        int v = E[i].to;
        if (!dfn[v]) {
            tarjan(v, u);
            low[u] = min(low[u], low[v]);
            if (low[v] >= dfn[u]) {
                if (u == fa)++child;
                else is[u] = true;
            }
        }
        else low[u] = min(dfn[v], low[u]);
    }if (child >= 2 && u == fa)is[u] = true;
}

int N;
int main() {
    while (scanf("%d", &N), N) {
        fill(is, is + max_n, false);
        fill(dfn, dfn + max_n, 0);
        fill(low, low + max_n, 0);
        fill(head, head + max_n, 0);
        cnt = 1;tot = 0;
        int u;int to;char c;
        while (scanf("%d", &u), u) {
            while (scanf("%c", &c), c != '\n') {
                scanf("%d", &to);add(u, to);add(to, u);
            }
        }for (int i = 1;i <= N;++i)
            if (!dfn[i])
                tarjan(i, i);
        int ans = 0;
        for (int i = 1;i <= N;++i)ans += is[i];
        printf("%d\n", ans);
    }
}