#include<iostream> #include<cstdio> #include<string> #include<cstring> #include<algorithm> #include<vector> #include<queue> using namespace std; int n,m; const int maxn=1e4+2; const int maxm=5e4+2; int degree[maxn]; int fa[maxn]; struct edge{ int to; int nxt; }e[2*maxm]; int head[maxn]; int tot; void init(){ memset(head,-1,sizeof(head)); tot=0; memset(degree,0,sizeof(degree)); } void add(int u,int v){ e[tot].to=v; e[tot].nxt=head[u]; head[u]=tot++; } int getfa(int u){ if(fa[u]==u) return u; return fa[u]=getfa(fa[u]); } void merge(int u,int v){ int fu=getfa(u); int fv=getfa(v); if(fu!=fv){ fa[u]=fa[v]; } } bool judge(){ for(int i=1;i<=n;i++){ fa[i]=i; } for(int u=1;u<=n;u++){ for(int i=head[u];i!=-1;i=e[i].nxt){ int v=e[i].to; merge(u,v); } } int cnt=0; for(int i=1;i<=n;i++){ if(fa[i]==i) cnt++; } if(cnt==1) return true; return false; } int main(){ while(~scanf("%d%d",&n,&m)){ init(); int u,v; for(int i=1;i<=m;i++){ scanf("%d%d",&u,&v); degree[u]++; degree[v]++; add(u,v); add(v,u); } bool connected=judge(); if(!connected){ printf("Part\n"); continue; } int cnt=0; for(int i=1;i<=n;i++){ if(degree[i]%2) cnt++; } if(cnt==0||cnt==2) printf("Full\n"); else printf("Part\n"); } return 0; }
原文地址:https://www.cnblogs.com/itcsl/p/9191522.html
时间: 2024-10-20 04:17:42