(beginer) DFS (二分图判定) UVA 11080 Place the Guards
来源:互联网 发布:程序员帅哥 编辑:程序博客网 时间:2024/05/16 09:26
Problem G
Place the Guards
Input: Standard Input
Output: Standard Output
In the country of Ajabdesh there are some streets and junctions. Each street connects 2 junctions. The king of Ajabdesh wants to place some guards in some junctions so that all the junctions and streets can be guarded by them. A guard in a junction can guard all the junctions and streets adjacent to it. But the guards themselves are not gentle. If a street is guarded by multiple guards then they start fighting. So the king does not want the scenario where a street may be guarded by two guards. Given the information about the streets and junctions of Ajabdesh, help the king to find the minimum number of guards needed to guard all the junctions and streets of his country.
Input:
The first line of the input contains a single integer T (T<80) indicating the number of test cases. Each test case begins with 2 integers v (1 ≤ v ≤ 200) and e (0 ≤ e ≤ 10000.). v is the number of junctions and e is the number of streets. Each of the next e line contains 2 integer f and t denoting that there is a street between f and t. All the junctions are numbered from 0 to v-1.
Output:
For each test case output in a single line an integer m denoting the minimum number of guards needed to guard all the junctions and streets. Set the value of m as -1 if it is impossible to place the guards without fighting.
Sample Input Output for Sample Input
2
4 2
0 1
2 3
5 5
0 1
1 2
2 3
0 4
3 4
2
-1
- (beginer) DFS (二分图判定) UVA 11080 Place the Guards
- UVA 11080 - Place the Guards(二分图判定)
- uva 11080 - Place the Guards(二分图染色)
- UVA-11080 Place the Guards(二分图染色)
- UVA11080- Place the Guards-(二分图染色)-dfs
- UVa 11080 Place the Guards
- UVA11080- Place the Guards(二分图染色)
- UVA11080 Place the Guards
- zoj 1654 Place the Robots 二分图匹配DFS实现
- UVa 10004 Bicoloring(二分图判定+DFS)
- 二分图判定 DFS版
- uva 11396 二分图判定
- ZJU 1654 Place the Robots(二分图)
- ZOJ1654 place the robots(二分图匹配)
- ZOJ1654 Place the Robots (二分图匹配)
- (beginer)DFS UVA 11396 Claw Decomposition
- UVa 11396 - Claw Decomposition(二分图判定,染色法,dfs)
- 二分图的判定模板(dfs,bfs)
- photoshop批处理改变图片大小
- (beginer) DFS LA3486 Cells
- (beginer)DFS (双连通分量) UVA 10765 Doves and bombs
- (beginer)DFS (2-SAT) UVA 11294 Wedding
- (beginer)DFS (dfs) UVA 10319 Manhattan
- (beginer) DFS (二分图判定) UVA 11080 Place the Guards
- (beginer)DFS (强连通)UVA 11504 Dominos
- (beginer)DFS (桥...边-双连通分量) UVA 610 - Street Directions
- (intermediate) DFS (高精度+找环) UVA 1361 Cactus
- 免费才是王道:盘点开发者须知的25个免费数据可视化工具
- (intermediate)DFS (边-双连通) UVA 10972 RevolC FaeLoN
- (intermediate)DFS UVA 11604 General Sultan
- (intermediate)DFS (强连通+缩点+拓扑排序) UVA 11098 - Battle II
- (beginer)最短路 UVA 10603 Fill