Codeforces Round 981 (Div. 3)

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
2033 Codeforces Round 981 (Div. 3) FINISHED False 8100 46625123 Oct. 24, 2024, 2:35 p.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 1990 ) G Sakurako and Chefir PROGRAMMING data structures dfs and similar dp trees

Given a tree with (n) vertices rooted at vertex (1). While walking through it with her cat Chefir, Sakurako got distracted, and Chefir ran away. To help Sakurako, Kosuke recorded his (q) guesses. In the (i)-th guess, he assumes that Chefir got lost at vertex (v_i) and had (k_i) stamina . Also, for each guess, Kosuke assumes that Chefir could move along the edges an arbitrary number of times: from vertex (a) to vertex (b), if (a) is an ancestor (^{\text{∗}}) of (b), the stamina will not change; from vertex (a) to vertex (b), if (a) is not an ancestor of (b), then Chefir's stamina decreases by (1). If Chefir's stamina is (0), he cannot make a move of the second type. For each assumption, your task is to find the distance to the farthest vertex that Chefir could reach from vertex (v_i), having (k_i) stamina . (^{\text{∗}})Vertex (a) is an ancestor of vertex (b) if the shortest path from (b) to the root passes through (a). The first line contains a single integer (t) ((1\le t\le 10^4)) — the number of test cases. Each test case is described as follows: The first line contains a single integer (n) ((2 \le n \le 2 \cdot 10^5)) — the number of vertices in the tree. The next (n-1) lines contain the edges of the tree. It is guaranteed that the given edges form a tree. The next line consists of a single integer (q) ((1\le q\le 2 \cdot 10^5)), which denotes the number of guesses made by Kosuke. The next (q) lines describe the guesses made by Kosuke, with two integers (v_i), (k_i) ((1\le v_i \le n, 0 \le k_i\le n)). It is guaranteed that the sum of (n) and the sum of (q) across all test cases does not exceed (2\cdot 10^5). For each test case and for each guess, output the maximum distance to the farthest vertex that Chefir could reach from the starting point (v_i) having (k_i) stamina . In the first example: In

Tutorials

135520

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
287803400 nathan_higgs G Oct. 24, 2024, 4:53 p.m. OK C++17 (GCC 7-32) TESTS 18 358 26521600
287809949 SpadeA261 G Oct. 24, 2024, 5:24 p.m. OK C++17 (GCC 7-32) TESTS 18 405 46284800
287819983 im.priyansh G Oct. 24, 2024, 6:43 p.m. OK C++17 (GCC 7-32) TESTS 18 421 33894400
287851871 chenxi2009 G Oct. 25, 2024, 3:20 a.m. OK C++17 (GCC 7-32) TESTS 18 421 43622400
287848385 chenxi2009 G Oct. 25, 2024, 2:29 a.m. OK C++17 (GCC 7-32) TESTS 18 421 43929600
287856382 DangKhoizzzz G Oct. 25, 2024, 4:21 a.m. OK C++17 (GCC 7-32) TESTS 18 452 48640000
287855992 nho_nyc G Oct. 25, 2024, 4:15 a.m. OK C++17 (GCC 7-32) TESTS 18 452 48640000
287865333 Luvidi G Oct. 25, 2024, 6:06 a.m. OK C++17 (GCC 7-32) TESTS 18 452 51814400
287803618 Zhirinovsky G Oct. 24, 2024, 4:54 p.m. OK C++17 (GCC 7-32) TESTS 18 483 60825600
287809825 Tahirliyev G Oct. 24, 2024, 5:23 p.m. OK C++17 (GCC 7-32) TESTS 18 483 87347200
287806118 cayaxi09 G Oct. 24, 2024, 5:04 p.m. OK C++20 (GCC 13-64) TESTS 18 312 70348800
287857738 AAAAAZBX G Oct. 25, 2024, 4:39 a.m. OK C++20 (GCC 13-64) TESTS 18 343 40243200
287851634 TJUHuangTao G Oct. 25, 2024, 3:16 a.m. OK C++20 (GCC 13-64) TESTS 18 343 43110400
287851117 Rating_10101010 G Oct. 25, 2024, 3:09 a.m. OK C++20 (GCC 13-64) TESTS 18 343 53043200
287850823 YooNisir G Oct. 25, 2024, 3:04 a.m. OK C++20 (GCC 13-64) TESTS 18 343 53043200
287855638 Bswoalwo G Oct. 25, 2024, 4:10 a.m. OK C++20 (GCC 13-64) TESTS 18 343 59904000
287832661 shrapnelzz G Oct. 24, 2024, 9:06 p.m. OK C++20 (GCC 13-64) TESTS 18 359 59187200
287855739 BadMi1k_ G Oct. 25, 2024, 4:12 a.m. OK C++20 (GCC 13-64) TESTS 18 374 83456000
287850769 HieuK G Oct. 25, 2024, 3:04 a.m. OK C++20 (GCC 13-64) TESTS 18 375 36249600
287806785 AnasMaged G Oct. 24, 2024, 5:07 p.m. OK C++20 (GCC 13-64) TESTS 18 375 46182400
287837945 osamaeh G Oct. 24, 2024, 10:40 p.m. OK C++23 (GCC 14-64, msys2) TESTS 18 312 234086400
287861991 manishjha91 G Oct. 25, 2024, 5:30 a.m. OK C++23 (GCC 14-64, msys2) TESTS 18 327 61132800
287807448 neal G Oct. 24, 2024, 5:10 p.m. OK C++23 (GCC 14-64, msys2) TESTS 18 359 65331200
287847991 Fiatiustitia G Oct. 25, 2024, 2:22 a.m. OK C++23 (GCC 14-64, msys2) TESTS 18 359 68096000
287821452 monui G Oct. 24, 2024, 6:57 p.m. OK C++23 (GCC 14-64, msys2) TESTS 18 359 96460800
287846485 F_Rio G Oct. 25, 2024, 1:53 a.m. OK C++23 (GCC 14-64, msys2) TESTS 18 374 52428800
287847102 Anon_Tokyo G Oct. 25, 2024, 2:06 a.m. OK C++23 (GCC 14-64, msys2) TESTS 18 374 58265600
287821384 monui G Oct. 24, 2024, 6:57 p.m. OK C++23 (GCC 14-64, msys2) TESTS 18 374 96460800
287851097 k1nsom G Oct. 25, 2024, 3:08 a.m. OK C++23 (GCC 14-64, msys2) TESTS 18 374 111206400
287835572 LoKl G Oct. 24, 2024, 9:51 p.m. OK C++23 (GCC 14-64, msys2) TESTS 18 390 49459200
287863151 lyongwolf G Oct. 25, 2024, 5:43 a.m. OK Java 21 TESTS 18 765 68300800
287832114 dusty.and.rusty G Oct. 24, 2024, 8:58 p.m. OK Java 21 TESTS 18 1656 112025600
287865183 arnabmanna G Oct. 25, 2024, 6:05 a.m. OK Java 21 TESTS 18 2609 258662400
287864064 InfinityX G Oct. 25, 2024, 5:53 a.m. OK Java 8 TESTS 18 859 236134400
287851064 yvbf G Oct. 25, 2024, 3:08 a.m. OK Java 8 TESTS 18 2014 114892800
287802829 yvbf G Oct. 24, 2024, 4:51 p.m. OK Java 8 TESTS 18 2140 116428800
287814597 deepakgpt676 G Oct. 24, 2024, 5:56 p.m. OK PyPy 3 TESTS 18 2139 71884800
287804858 misorin G Oct. 24, 2024, 4:58 p.m. OK PyPy 3-64 TESTS 18 483 103936000
287810716 liupengsay G Oct. 24, 2024, 5:28 p.m. OK PyPy 3-64 TESTS 18 890 132505600
287807774 liupengsay G Oct. 24, 2024, 5:12 p.m. OK PyPy 3-64 TESTS 18 953 142848000
287842929 liupengsay G Oct. 25, 2024, 12:42 a.m. OK PyPy 3-64 TESTS 18 1093 91545600
287850023 Little_Sheep_Yawn G Oct. 25, 2024, 2:54 a.m. OK PyPy 3-64 TESTS 18 1093 92364800
287851474 gardengnome G Oct. 25, 2024, 3:14 a.m. OK PyPy 3-64 TESTS 18 1280 96153600
287854123 gardengnome G Oct. 25, 2024, 3:49 a.m. OK PyPy 3-64 TESTS 18 1421 88678400
287853234 gardengnome G Oct. 25, 2024, 3:37 a.m. OK PyPy 3-64 TESTS 18 1467 95334400
287852299 golomb G Oct. 25, 2024, 3:25 a.m. OK PyPy 3-64 TESTS 18 1562 85504000
287808224 liupengsay G Oct. 24, 2024, 5:14 p.m. OK PyPy 3-64 TESTS 18 1718 166502400
287816453 oneoone G Oct. 24, 2024, 6:11 p.m. OK Rust 2021 TESTS 18 1139 72601600

remove filters

Back to search problems