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.
ContestId |
Name |
Phase |
Frozen |
Duration (Seconds) |
Relative Time |
Start Time |
---|---|---|---|---|---|---|
1381 | Codeforces Round 658 (Div. 1) | FINISHED | False | 7200 | 142010711 | July 21, 2020, 2:35 p.m. |
Solved$ |
Index |
Name |
Type |
Tags |
Community Tag |
Rating |
---|---|---|---|---|---|---|
( 693 ) | D | The Majestic Brown Tree Snake | PROGRAMMING | dfs and similar dp greedy trees two pointers | 3000 |
B'There is an undirected tree of n vertices, connected by n-1 bidirectional edges. There is also a snake stuck inside of this tree. Its head is at vertex a and its tail is at vertex b . The snake 's body occupies all vertices on the unique simple path between a and b . The snake wants to know if it can reverse itself -- that is, to move its head to where its tail started, and its tail to where its head started. Unfortunately, the snake 's movements are restricted to the tree 's structure. In an operation, the snake can move its head to an adjacent vertex not currently occupied by the snake. When it does this, the tail moves one vertex closer to the head, so that the length of the snake remains unchanged. Similarly, the snake can also move its tail to an adjacent vertex not currently occupied by the snake. When it does this, the head moves one unit closer to the tail. Determine if it is possible to reverse the snake with some sequence of operations. The first line contains a single integer t ( 1 <= t <= 100 ) -- the number of test cases. The next lines contain descriptions of test cases. The first line of each test case contains three integers n,a,b ( 2 <= n <= 10^5,1 <= a,b <= n,a ne b ). Each of the next n-1 lines contains two integers u_i,v_i ( 1 <= u_i,v_i <= n,u_i ne v_i ), indicating an edge between vertices u_i and v_i . It is guaranteed that the given edges form a tree. It is guaranteed that the sum of n across all test cases does not exceed 10^5 . For each test case, output "YES" if it is possible for the snake to reverse itself, or "NO" otherwise. The first test case is pictured above. In the second test case, the tree is a path. We can show that the snake cannot reverse itself. In the third test case, we can show that the snake cannot reverse itself. In the fourth test case, an example solution is: (15,12) to (16,11) to (15,13) to (10,14) to (8,13) to '... |
Codeforces Round #658 Editorial |
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
---|---|---|---|---|---|---|---|---|---|---|---|
87596571 | xtqqwq | D | July 21, 2020, 5:26 p.m. | OK | GNU C++11 | TESTS | 28 | 61 | 8908800 | 3000 | |
87603794 | littlelittlehorse | D | July 21, 2020, 6:21 p.m. | OK | GNU C++11 | TESTS | 28 | 62 | 10240000 | 3000 | |
87620150 | xay5421 | D | July 21, 2020, 11:40 p.m. | OK | GNU C++11 | TESTS | 29 | 62 | 10342400 | 3000 | |
87591705 | EricHuang2003 | D | July 21, 2020, 4:30 p.m. | OK | GNU C++11 | TESTS | 28 | 62 | 20582400 | 3000 | |
87594226 | supy | D | July 21, 2020, 4:34 p.m. | OK | GNU C++11 | TESTS | 28 | 62 | 33177600 | 3000 | |
87612997 | duality | D | July 21, 2020, 8:28 p.m. | OK | GNU C++11 | TESTS | 28 | 124 | 11776000 | 3000 | |
87586752 | It5t | D | July 21, 2020, 4:20 p.m. | OK | GNU C++11 | TESTS | 28 | 171 | 8396800 | 3000 | |
87591946 | LMOliver | D | July 21, 2020, 4:31 p.m. | OK | GNU C++11 | TESTS | 28 | 265 | 9011200 | 3000 | |
87587190 | yashChandnani | D | July 21, 2020, 4:21 p.m. | OK | GNU C++14 | TESTS | 28 | 93 | 10137600 | 3000 | |
87622800 | NaimSS | D | July 22, 2020, 1:15 a.m. | OK | GNU C++14 | TESTS | 30 | 108 | 14131200 | 3000 | |
87627750 | Purple_wzy | D | July 22, 2020, 3:10 a.m. | OK | GNU C++14 | TESTS | 30 | 108 | 18944000 | 3000 | |
87596352 | ugly2333 | D | July 21, 2020, 5:25 p.m. | OK | GNU C++14 | TESTS | 28 | 109 | 8396800 | 3000 | |
87633108 | zhouzhendong | D | July 22, 2020, 4:51 a.m. | OK | GNU C++14 | TESTS | 30 | 140 | 17408000 | 3000 | |
87633090 | zhouzhendong | D | July 22, 2020, 4:50 a.m. | OK | GNU C++14 | TESTS | 30 | 140 | 17408000 | 3000 | |
87584659 | DmitryGrigorev | D | July 21, 2020, 4:15 p.m. | OK | GNU C++14 | TESTS | 28 | 156 | 17510400 | 3000 | |
87628980 | rama_pang | D | July 22, 2020, 3:36 a.m. | OK | GNU C++14 | TESTS | 30 | 233 | 27443200 | 3000 | |
87637593 | .ckodser. | D | July 22, 2020, 5:55 a.m. | OK | GNU C++14 | TESTS | 30 | 265 | 8089600 | 3000 | |
87598483 | zeronumber | D | July 21, 2020, 5:35 p.m. | OK | GNU C++14 | TESTS | 28 | 311 | 17817600 | 3000 | |
87630271 | __fr__y__ | D | July 22, 2020, 3:59 a.m. | OK | GNU C++17 | TESTS | 30 | 78 | 8704000 | 3000 | |
87587486 | Maksim1744 | D | July 21, 2020, 4:22 p.m. | OK | GNU C++17 | TESTS | 28 | 93 | 8601600 | 3000 | |
87604584 | wiwitrifai | D | July 21, 2020, 6:30 p.m. | OK | GNU C++17 | TESTS | 28 | 93 | 9318400 | 3000 | |
87582982 | receed | D | July 21, 2020, 4:12 p.m. | OK | GNU C++17 | TESTS | 28 | 93 | 9728000 | 3000 | |
87596213 | Wild_Hamster | D | July 21, 2020, 5:24 p.m. | OK | GNU C++17 | TESTS | 28 | 93 | 10137600 | 3000 | |
87599360 | cerberus97 | D | July 21, 2020, 5:41 p.m. | OK | GNU C++17 | TESTS | 28 | 108 | 8704000 | 3000 | |
87594304 | natsugiri | D | July 21, 2020, 4:34 p.m. | OK | GNU C++17 | TESTS | 28 | 108 | 10649600 | 3000 | |
87618699 | timf1089 | D | July 21, 2020, 10:48 p.m. | OK | GNU C++17 | TESTS | 28 | 108 | 17817600 | 3000 | |
87603197 | vipjml | D | July 21, 2020, 6:15 p.m. | OK | GNU C++17 | TESTS | 28 | 109 | 8806400 | 3000 | |
87594930 | RNS_CUS | D | July 21, 2020, 4:34 p.m. | OK | GNU C++17 | TESTS | 28 | 109 | 11264000 | 3000 | |
87583704 | ecnerwala | D | July 21, 2020, 4:13 p.m. | OK | GNU C++17 (64) | TESTS | 28 | 93 | 10649600 | 3000 | |
87586314 | majk | D | July 21, 2020, 4:19 p.m. | OK | GNU C++17 (64) | TESTS | 28 | 93 | 11161600 | 3000 | |
87596220 | Noam13 | D | July 21, 2020, 5:24 p.m. | OK | GNU C++17 (64) | TESTS | 28 | 93 | 11264000 | 3000 | |
87597401 | Ari | D | July 21, 2020, 5:30 p.m. | OK | GNU C++17 (64) | TESTS | 28 | 93 | 11468800 | 3000 | |
87582500 | maroonrk | D | July 21, 2020, 4:10 p.m. | OK | GNU C++17 (64) | TESTS | 28 | 108 | 19865600 | 3000 | |
87602012 | Kuroni | D | July 21, 2020, 6:05 p.m. | OK | GNU C++17 (64) | TESTS | 28 | 109 | 11571200 | 3000 | |
87611242 | Monogon | D | July 21, 2020, 7:57 p.m. | OK | GNU C++17 (64) | TESTS | 28 | 124 | 16588800 | 3000 | |
87585425 | Geothermal | D | July 21, 2020, 4:17 p.m. | OK | GNU C++17 (64) | TESTS | 28 | 124 | 19251200 | 3000 | |
87598438 | olphe | D | July 21, 2020, 5:35 p.m. | OK | GNU C++17 (64) | TESTS | 28 | 155 | 24268800 | 3000 | |
87596226 | neal | D | July 21, 2020, 5:24 p.m. | OK | GNU C++17 (64) | TESTS | 28 | 155 | 29184000 | 3000 |
Back to search problems