原创 UVA 10765 Doves and bombs(強聯通)
#include<iostream> #include<vector> #include<cstring> #include<algorithm> using namespace std; const int maxn=10000+5;
原创 HDU 4751 Divide Groups(二分圖判斷)
給出的圖是一張有向圖,代表i認識j,那麼line[i][j]==false||line[j][i]==false代表i和j不是相互認識,那麼他們肯定
原创 UVA 10600 ACM Contest and Blackout(最小生成樹and次小生成樹)
拿的最小瓶頸路LCA模板做的,感覺好浪費。#include<iostream> #include<cstring> #include<vec
原创 HDU 2444 The Accomodation of Students(二分圖判斷+最大匹配)
#include<iostream> #include<cstring> using namespace std; const int maxn=200+5; int head[maxn*maxn],to[maxn*maxn],Next[
原创 UVA 1327 King's Quest(強聯通+二分圖)
參考:http://www.cnblogs.com/zxndgv/archive/2011/08/06/2129333.html #include<iostream> #include<cstring> #include<vector>
原创 UVA 12168 Cat vs. Dog(最大獨立集)
這個看的出來是求最大獨立集,但是一開始一直是貓和狗矛盾,用毛和狗在做最大匹配。 但是題目要求是最多滿足多少人的要求,才發現,是人的最大獨立集。#include<iostream> #include<cstring> using names
原创 UVA 1405 The Great Wall Game(最佳二分圖匹配)
一開始理所當然的認爲橫排和縱排應該是橫座標和縱座標和的平均值,但是WA了好幾次。檢查了一下,好像也就這麼一個可疑點,算算時間複雜度也不會T,就直接暴力了,然後就過了= =。 #include<iostream> using namespa
原创 UVA 11396 Claw Decomposition(二分圖判斷)
如果一個節點是一個爪的中心,那麼他只能與其餘三個輔助點相連,那麼就可以發現這是一張二分圖,X爲爪的中心,Y爲三個腳,建完圖染下色就可以了。Claw
原创 POJ 3487 The Stable Marriage Problem(穩定婚姻問題)
#include<iostream> #include<queue> #include<cmath> #include<map> #include<cstdio> #include<algorithm> using namespace s
原创 UVA 11419 SAM I AM(二分圖最小覆蓋+答案輸出)
這個板子直接可以用了。 #include<iostream> #include<cstring> #include<vector> #include<algorithm> using namespace std; const int ma
原创 UVA 12083 Guardian of Decency(最小獨立集)
最大獨立集=點數-最大匹配。#include<iostream> #include<cstring> using namespace std; co
原创 UVA 1201 Taxi Cab Scheme(最小路徑覆蓋)
#include<iostream> #include<cstring> #include<cmath> using namespace std; const int maxn=500+5; int x1[maxn],y[maxn],x2
原创 UVA 1349 Optimal Bus Route Design(KM判環)
#include<iostream> #include<cstring> using namespace std; const int maxn=100+5; const int inf=(1<<30); int w[maxn][maxn
原创 UVA 10972 RevolC FaeLoN(邊雙聯通+縮點)
#include<iostream> #include<vector> #include<cstring> using namespace std; const int maxn=1000+5; const int maxm=maxn*m
原创 UVA 1395 Slim Span(枚舉)
#include<iostream> #include<vector> #include<algorithm> #include<cstring> using namespace std; const int maxn=100+5; co