[Solution] Lenient Vertex Cover Codeforces Solution | Codeforces Problem Solution 2022
You are given a simple connected undirected graph, consisting of vertices and edges. The vertices are numbered from to .
A vertex cover of a graph is a set of vertices such that each edge has at least one of its endpoints in the set.
Let's call a lenient vertex cover such a vertex cover that at most one edge in it has both endpoints in the set.
Find a lenient vertex cover of a graph or report that there is none. If there are multiple answers, then print any of them.
The first line contains a single integer () — the number of testcases.
The first line of each testcase contains two integers and (; ) — the number of vertices and the number of edges of the graph.
Each of the next lines contains two integers and (; ) — the descriptions of the edges.
For each testcase, the graph is connected and doesn't have multiple edges. The sum of over all testcases doesn't exceed . The sum of over all testcases doesn't exceed .
For each testcase, the first line should contain YES if a lenient vertex cover exists, and NO otherwise. If it exists, the second line should contain a binary string of length , where means that vertex is in the vertex cover, and means that vertex isn't.
If there are multiple answers, then print any of them.
Join Now for Solution:-
No comments:
Post a Comment