日记2.17(1)
枚举二分图 Color Graph 题目让给无向图边刷红色,不允许奇环全红,相当于删除边,使得图中只有偶环,只有偶环即2分图,看题目数据范围容易推得是枚举题。 于是这一题就是枚举二分图左边的点 code:来自某大佬的博客: https://www.cnblogs.com/ucprer/p/11931263.html # include <bits/stdc++.h> using namespace std ; const int maxn = 105 ; const int maxm = 1e4 + 5 ; struct edge { int u , v ; } E [ maxm ] ; int tot = 0 ; void addedge ( int u , int v ) { E [ ++ tot ] . u = u ; E [ tot ] . v = v ; } int color [ maxn ] ; int main ( ) { int T ; cin >> T ; for ( int kase = 1 ; kase <= T ; kase ++ ) { int n , m ; scanf ( "%d%d" , & n , & m ) ; fill ( color , color + 1 + n , 0 ) ; tot = 0 ; for ( int i = 1 ; i