///////////////////////////////////////////////////////////////////////////////////////////////////////
tt267
Disclaimer: This document is subject to the following agreement free reprint-non-commercial-non-derivative-retention Attribution | Creative Commons by-nc-nd 3.0
Reprint Please specify: http://blog.csdn.net/tt2767/article/details/45420067
///////////////////////////////////////////////////////////////////////////////////////////////////////
Game Link: http://hihocoder.com/contest/hiho49
Title Link: http://hihocoder.com/problemset/problem/1176
1. Record and determine the degree of each point
2. Direct use and check set to determine whether the undirected graph is connected
#include <string.h>#include <stdio.h>#define N 1000000intPre[n];intRank[n];intEdge[n];intN,m,u,v;intFindintx);intJoinintXinty);voidInivoid);intSame (intXinty);BOOLSolve ();intMain () {ini ();memset(Edge,0,sizeof(Edge));scanf("%d%d", &n,&m); for(inti =0; I < m; i++) {scanf("%d%d", &u,&v); edge[--u]++;//Don't forget to reduce the value by 1edge[--v]++; Join (U,V); }puts(Solve ()?"Full":"part");return 0;}BOOLSolve () {BOOLFlag =true;intCount =0; for(inti =1; I < n; i++)//Determine if the diagram is connected{if(!same (0, i)) {flag=false; Break; } } for(inti =0; I < m; i++)//Statistics There are several sides that are odd{if(Edge[i]%2!=0) count++; }if((Count = =0|| Count = =2) && flag)return true;return false;}voidInivoid){intI for(i =0; i < N; i++) Pre[i] = i,rank[i] =0;}intJoinintXintY) {intFX = Find (x), FY = find (y);if(FX = = FY)return 0;if(Rank[fx] > Rank[fy]) {Pre[fy] = FX; }Else{PRE[FX] = FY;if(Rank[fx] = = Rank[fy]) rank[fy]++; }}intFind (intx) {intR = x; while(r! = Pre[r]) R = Pre[r];inti = x,j; while(r! = Pre[i]) {j = pre[i]; Pre[i] = r; i = j; }returnR;}intSame (intXintY) {returnFind (x) = = Find (y);}
Hiho 49th Week (Oralu's verdict) 49