Aim - To find the minimum vortex cover of a tree. Given an unweighted, undirected tree, find it's minimum vortex cover. Having checked if the Graph is Bipartite or not and also made the 2 sets of vertices, is it true the minimum of these 2 sets returns the minimum cover. If yes, what seems to be the error in the following code? The same code successfully passed the below mentioned question on a Codeforces contest, however it would give a WA if used (with slight modification as per the input) for the mentioned Spoj problem.
And yes, obvious changes in the output format were made while submitting on Spoj.
Codeforces question to check if Bipartite or not.
http://www.codeforces.com/problemset/problem/688/C
My submission
enter code here
http://ideone.com/PwduxV
Question on spoj to find the minimum cover.
An undirected tree is always bipartite, but it's not guaranteed that one of the sets will be the minimum cover.
Consider the simple graph:
1-3
2-3
3-4
4-5
4-6
The minimum cover is {3,4}, but you can divide it into bipartite sets {1,2,4}, {3,5,6}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.