Solutions are presented as using the least memory and the fastest execution time. It also takes the top
10 most recent solutions from each language. If you want to limit to a specific index, click the
"Solved" button and go to that problem.
Problems
B"You are given a simple connected undirected graph, consisting of n vertices and m edges. The vertices are numbered from 1 to n . 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 t ( 1 <= t <= 10^4 ) -- the number of testcases. The first line of each testcase contains two integers n and m ( 2 <= n <= 10^6 ; n - 1 <= m <= min(10^6, frac{n cdot (n - 1)}{2}) ) -- the number of vertices and the number of edges of the graph. Each of the next m lines contains two integers v and u ( 1 <= v, u <= n ; v neq u ) -- the descriptions of the edges. For each testcase, the graph is connected and doesn't have multiple edges. The sum of n over all testcases doesn't exceed 10^6 . The sum of m over all testcases doesn't exceed 10^6 . 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 s of length n , where s_i = 1 means that vertex i is in the vertex cover, and s_i = 0 means that vertex i isn't. If there are multiple answers, then print any of them. Here are the graphs from the first example. The vertices in the lenient vertex covers are marked red. "... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
157084818 |
srikkanthr |
F |
May 13, 2022, 6:11 p.m. |
OK |
GNU C++14 |
TESTS |
29 |
1138 |
112640000 |
|
|
157068911 |
jumpmelon |
F |
May 13, 2022, 4:21 p.m. |
OK |
GNU C++14 |
TESTS |
29 |
1231 |
96358400 |
|
|
157077655 |
Kaitokid |
F |
May 13, 2022, 4:58 p.m. |
OK |
GNU C++14 |
TESTS |
29 |
1247 |
113356800 |
|
|
157106569 |
BEAR0131 |
F |
May 14, 2022, 2:36 a.m. |
OK |
GNU C++14 |
TESTS |
29 |
1310 |
118374400 |
|
|
157064895 |
wzpakioi |
F |
May 13, 2022, 4:08 p.m. |
OK |
GNU C++14 |
TESTS |
29 |
1341 |
118681600 |
|
|
157104649 |
L7-56 |
F |
May 14, 2022, 1:48 a.m. |
OK |
GNU C++14 |
TESTS |
29 |
1357 |
178995200 |
|
|
157104669 |
bkifhr9 |
F |
May 14, 2022, 1:48 a.m. |
OK |
GNU C++14 |
TESTS |
29 |
1372 |
178995200 |
|
|
157077383 |
lgzhy12138 |
F |
May 13, 2022, 4:56 p.m. |
OK |
GNU C++14 |
TESTS |
29 |
1466 |
104038400 |
|
|
157103047 |
fscbti |
F |
May 14, 2022, 1:01 a.m. |
OK |
GNU C++14 |
TESTS |
29 |
2089 |
310681600 |
|
|
157112831 |
7as__7 |
F |
May 14, 2022, 4:41 a.m. |
OK |
GNU C++14 |
TESTS |
29 |
2105 |
120934400 |
|
|
remove filters
Back to search problems