#include<iostream> #include<cstring> #include<cstdio> #include<algorithm> #include<cmath> using namespace std; int read() { int x=0,f=1; char ch=getchar(); while (ch<‘0‘ || ch>‘9‘) {if (ch==‘-‘) f=-1; ch=getchar();} while (ch>=‘0‘ && ch<=‘9‘) {x=x*10+ch-‘0‘; ch=getchar();} return x*f; } struct EdgeNode{int next,to;}edge[maxn<<2]; int head[maxn],cnt; void add(int u,int v,int w) {cnt++; edge[cnt].next=head[u]; head[u]=cnt; edge[cnt].to=v;} void insert(int u,int v,int w) {add(u,v); add(v,u);} int n,m; void CactusDP(int now) { } void TreeDP(int now,int last) { dfn[now]=low[now]=++t; for (int i=head[now]; i; i=edge[i].next) if (edge[i].to!=last) { if (deep[edge[i].to]) {low[now]=min(dfn[edge[i].to],low[now]); continue;} fa[edge[i].to]=now; deep[edge[i].to]=deep[now]+1; DFS(edge[i].to,now); low[now]=min(low[now],low[edge[i].to]); } } int main() { n=read(),m=read(); for (int i=1; i<=n; i++) HX[i]=read(); for (int u,v,i=1; i<=m; i++) u=read(),v=read(),insert(u,v); for (int i=1; i<=n; i++) if (!dfn[i]) DFS(i); printf("%d\n",ans); return 0; }
时间: 2024-11-09 16:38:19