Codeforces Round 947 (Div. 1 + Div. 2)

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
1975 Codeforces Round 947 (Div. 1 + Div. 2) FINISHED False 10800 20532263 May 25, 2024, 2:35 p.m.

Problems

Solved$
Index
Name
Type
Tags
Community Tag
Rating
( 6273 ) D Paint the Tree PROGRAMMING brute force dfs and similar dp greedy shortest paths trees 1700

B'378QAQ has a tree with n vertices. Initially, all vertices are white. There are two chess pieces called P_A and P_B on the tree. P_A and P_B are initially located on vertices a and b respectively. In one step, 378QAQ will do the following in order: Initially, the vertex a is painted red. If a=b , the vertex a is painted blue instead. Note that both the chess pieces must be moved in each step. Two pieces can be on the same vertex at any given time. 378QAQ wants to know the minimum number of steps to paint all vertices blue. Each test contains multiple test cases. The first line contains the number of test cases t ( 1 <= q t <= q 10^4 ). The description of the test cases follows. The first line of each test case contains one integer n ( 1 <= q n <= q 2 cdot 10^5 ). The second line of each test case contains two integers a and b ( 1 <= q a,b <= q n ). Then n - 1 lines follow, each line contains two integers x_i and y_i ( 1 <= x_i,y_i <= n ), indicating an edge between vertices x_i and y_i . It is guaranteed that these edges form a tree. It is guaranteed that the sum of n over all test cases does not exceed 2 cdot 10^5 . For each test case, output the minimum number of steps to paint all vertices blue. In the first test case, 378QAQ can paint all vertices blue in the following order: '...

Tutorials

editorial_zh.pdf

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
262808278 g1ove D May 26, 2024, 11:32 p.m. OK C++14 (GCC 6-32) TESTS 39 156 8294400 1700
262836450 xiehao20253 D May 27, 2024, 6:38 a.m. OK C++14 (GCC 6-32) TESTS 39 156 8294400 1700
263689861 5k_sync_closer D June 2, 2024, 1:28 a.m. OK C++14 (GCC 6-32) TESTS 39 171 8294400 1700
263559360 aaa12321 D June 1, 2024, 12:46 a.m. OK C++14 (GCC 6-32) TESTS 39 171 8294400 1700
262950608 yb13558h D May 28, 2024, 3:23 a.m. OK C++14 (GCC 6-32) TESTS 39 171 10854400 1700
262841917 SimpleCloud D May 27, 2024, 7:20 a.m. OK C++14 (GCC 6-32) TESTS 39 171 15155200 1700
262855506 10000point D May 27, 2024, 9:13 a.m. OK C++14 (GCC 6-32) TESTS 39 186 8294400 1700
262816400 SamHJD D May 27, 2024, 2:56 a.m. OK C++14 (GCC 6-32) TESTS 39 187 8294400 1700
263012725 xieliren2021 D May 28, 2024, 12:50 p.m. OK C++14 (GCC 6-32) TESTS 39 187 8806400 1700
262860311 luanyanjia D May 27, 2024, 9:53 a.m. OK C++14 (GCC 6-32) TESTS 39 187 11468800 1700
262892808 sjnnjs D May 27, 2024, 2:12 p.m. OK C++17 (GCC 7-32) TESTS 39 171 22732800 1700
263072795 H_4 D May 29, 2024, 12:21 a.m. OK C++17 (GCC 7-32) TESTS 39 171 24166400 1700
263155518 hshhh_ D May 29, 2024, 2:25 p.m. OK C++17 (GCC 7-32) TESTS 39 186 14745600 1700
263169874 gyash9878 D May 29, 2024, 4:55 p.m. OK C++17 (GCC 7-32) TESTS 39 187 12288000 1700
262986111 mingjunyi1024helloworld D May 28, 2024, 9:09 a.m. OK C++17 (GCC 7-32) TESTS 39 187 14131200 1700
263123905 mingjunyi1024helloworld D May 29, 2024, 10:11 a.m. OK C++17 (GCC 7-32) TESTS 39 187 14131200 1700
263015761 kenkukumaduo D May 28, 2024, 1:13 p.m. OK C++17 (GCC 7-32) TESTS 39 187 48025600 1700
263039926 wangpp D May 28, 2024, 4:28 p.m. OK C++17 (GCC 7-32) TESTS 39 202 25190400 1700
263694112 shrey71 D June 2, 2024, 3:07 a.m. OK C++17 (GCC 7-32) TESTS 39 218 10956800 1700
263684500 mohamedeltair D June 1, 2024, 10:30 p.m. OK C++17 (GCC 7-32) TESTS 39 218 11673600 1700
262817849 xiang_xiang D May 27, 2024, 3:20 a.m. OK C++20 (GCC 13-64) TESTS 39 109 81203200 1700
262833827 LYH.cpp D May 27, 2024, 6:12 a.m. OK C++20 (GCC 13-64) TESTS 39 140 21094400 1700
263017802 xuemanowo D May 28, 2024, 1:30 p.m. OK C++20 (GCC 13-64) TESTS 39 155 18841600 1700
263017736 xuemanowo D May 28, 2024, 1:29 p.m. OK C++20 (GCC 13-64) TESTS 39 155 18841600 1700
262813679 resstifnurv D May 27, 2024, 2:02 a.m. OK C++20 (GCC 13-64) TESTS 39 155 26931200 1700
262914259 star_xiangmy D May 27, 2024, 5:10 p.m. OK C++20 (GCC 13-64) TESTS 39 155 44134400 1700
262820068 orzdevinwang D May 27, 2024, 3:56 a.m. OK C++20 (GCC 13-64) TESTS 39 155 121958400 1700
262836277 N_z__ D May 27, 2024, 6:37 a.m. OK C++20 (GCC 13-64) TESTS 39 171 16896000 1700
262814378 HuHu_Fei D May 27, 2024, 2:18 a.m. OK C++20 (GCC 13-64) TESTS 39 171 22016000 1700
263147684 wuzihan D May 29, 2024, 1:25 p.m. OK C++20 (GCC 13-64) TESTS 39 186 23654400 1700
263629383 nguyenquocthao00 D June 1, 2024, 12:33 p.m. OK Go TESTS 39 234 96972800 1700
262857527 Tobo D May 27, 2024, 9:29 a.m. OK Go TESTS 39 374 53555200 1700
263405425 MdAbedin D May 31, 2024, 3:47 a.m. OK Java 21 TESTS 39 655 66150400 1700
262960206 amit_roy D May 28, 2024, 5:17 a.m. OK Java 21 TESTS 39 687 65024000 1700
263648621 Magical D June 1, 2024, 3:22 p.m. OK Java 21 TESTS 39 842 58777600 1700
262973857 Zhanzhe_Lee D May 28, 2024, 7:24 a.m. OK Java 21 TESTS 39 843 90009600 1700
262805314 SamyajitDas D May 26, 2024, 10:08 p.m. OK Java 21 TESTS 39 889 96256000 1700
262804543 SD125 D May 26, 2024, 9:50 p.m. OK Java 21 TESTS 39 889 96256000 1700
262907667 daksh_02 D May 27, 2024, 4:10 p.m. OK Java 21 TESTS 39 905 91750400 1700
263615666 _habibur_rahman D June 1, 2024, 10:47 a.m. OK Java 21 TESTS 39 952 75161600 1700
262982563 dzhi D May 28, 2024, 8:38 a.m. OK Java 21 TESTS 39 967 80691200 1700
263639615 c1415926 D June 1, 2024, 2:04 p.m. OK Java 21 TESTS 39 1046 106905600 1700
262897678 yvbf D May 27, 2024, 2:51 p.m. OK Java 8 TESTS 39 592 70860800 1700
262897912 wat2 D May 27, 2024, 2:52 p.m. OK Java 8 TESTS 39 624 70451200 1700
263153921 leonlian D May 29, 2024, 2:12 p.m. OK Java 8 TESTS 39 765 55193600 1700
263615827 _habibur_rahman D June 1, 2024, 10:49 a.m. OK Java 8 TESTS 39 780 41369600 1700
263602751 YMSeah D June 1, 2024, 8:59 a.m. OK PyPy 3 TESTS 39 515 25088000 1700
262859472 acorn11 D May 27, 2024, 9:46 a.m. OK PyPy 3-64 TESTS 39 468 61030400 1700
263016631 Exyon75 D May 28, 2024, 1:20 p.m. OK PyPy 3-64 TESTS 39 483 41779200 1700
263168835 bhataktaBhai D May 29, 2024, 4:40 p.m. OK PyPy 3-64 TESTS 39 499 51814400 1700
262715565 the_last_smilodon D May 26, 2024, 2:18 p.m. OK PyPy 3-64 TESTS 39 515 64409600 1700
263252914 bergus D May 30, 2024, 1:07 p.m. OK PyPy 3-64 TESTS 39 530 50278400 1700
262713466 jgs03177 D May 26, 2024, 1:58 p.m. OK PyPy 3-64 TESTS 39 561 42188800 1700
263013424 Lanzy D May 28, 2024, 12:55 p.m. OK PyPy 3-64 TESTS 39 577 52736000 1700
263180000 sohampalkar D May 29, 2024, 7:53 p.m. OK PyPy 3-64 TESTS 39 608 92876800 1700
263179173 sohampalkar D May 29, 2024, 7:38 p.m. OK PyPy 3-64 TESTS 39 640 92774400 1700
262833069 gardengnome D May 27, 2024, 6:04 a.m. OK PyPy 3-64 TESTS 39 687 54169600 1700
262716664 2210080018 D May 26, 2024, 2:30 p.m. OK Python 3 TESTS 39 906 47308800 1700
263071024 VioletVal D May 28, 2024, 11:31 p.m. OK Python 3 TESTS 39 1078 63795200 1700
263041556 asiftreadingonthinice D May 28, 2024, 4:42 p.m. OK Python 3 TESTS 39 1327 58982400 1700
262991569 EBeason D May 28, 2024, 9:57 a.m. OK Python 3 TESTS 39 1421 61849600 1700
262957910 PlaceOrientedProgrammer D May 28, 2024, 4:54 a.m. OK Rust 2021 TESTS 39 171 34201600 1700
263125561 BetterThanNobita D May 29, 2024, 10:25 a.m. OK Rust 2021 TESTS 39 171 42700800 1700
262965846 kiddoos D May 28, 2024, 6:13 a.m. OK Rust 2021 TESTS 39 249 36659200 1700
263061408 Maksim1744 D May 28, 2024, 8:06 p.m. OK Rust 2021 TESTS 39 374 66867200 1700
263054406 Maksim1744 D May 28, 2024, 6:40 p.m. OK Rust 2021 TESTS 39 390 66867200 1700
263173816 Maksim1744 D May 29, 2024, 5:54 p.m. OK Rust 2021 TESTS 39 452 66867200 1700
263125360 BetterThanNobita D May 29, 2024, 10:24 a.m. OK Rust 2021 TESTS 39 546 44339200 1700

remove filters

Back to search problems