Codeforces Round 1062 (Div. 4)

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
2167 Codeforces Round 1062 (Div. 4) FINISHED False 8100 14743523 Oct. 28, 2025, 2:35 p.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 7056 ) F Tree, TREE!!! PROGRAMMING data structures dp trees

Behruzbek received a tree (^{\text{∗}}) with (n) nodes. For a chosen root (^{\text{†}}) (r), Behruzbek wants to find cuteness of the tree. Consider every set of (k) distinct nodes of the tree. For each such set, compute its lowest common ancestor ( LCA ) in the tree when it is rooted at (r). Let (S_r) be the set of all distinct nodes obtained this way; then cuteness of the tree is (|S_r|), where (|S|) means the number of distinct elements. After discovering the cuteness of trees, Behruzbek became interested in finding the kawaiiness of the tree! Kawaiiness is defined as: () \sum_{r = 1}^{n} |S_r| = |S_1| + |S_2| + \dots + |S_n| () Unfortunately, Behruzbek is feeling sleepy now. Please help Behruzbek by finding the kawaiiness of the tree! (^{\text{∗}})A tree is a connected graph without cycles. (^{\text{†}})A rooted tree is a tree where one vertex is special and called the root. The first line contains the number of test cases (t) ((1 \leq t \leq 10^{4})). The first line of each test case contains two integers (n) and (k) ((2 \leq k \leq n \leq 2\cdot 10^{5})) — the number of vertices in the tree and the number of distinct integers to be chosen. The following (n-1) lines of each test case describe the tree. Each of the lines contains two integers (u) and (v) ((1 \leq u,v \leq n), (u \ne v)) that indicate an edge between vertex (u) and (v). 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 one integer — the value of (\sum\limits_{r=1}^n |S_r|). Let (f(i) = |S_i|) For the third example: Root is (1), only (1) and (2) nodes can be obtained. For example, we can choose: (LCA(4, 5, 6) = 1) and (LCA(2, 4, 5) = 2). As a result, (f(1) = 2). Root is (2), only (1) and (2) nodes can be obtained. For example,

Tutorials

Arpa Video Tutorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
346526761 VaHiX F Oct. 29, 2025, 7:27 p.m. OK C++17 (GCC 7-32) TESTS 26 171 8601600
346524201 h.fugah F Oct. 29, 2025, 7:03 p.m. OK C++17 (GCC 7-32) TESTS 26 202 12288000
346559611 orzthxuan F Oct. 30, 2025, 3:38 a.m. OK C++17 (GCC 7-32) TESTS 26 218 6758400
346398666 ustcyyw F Oct. 29, 2025, 2:02 a.m. OK C++17 (GCC 7-32) TESTS 26 218 11468800
346528768 ToBeContinued.. F Oct. 29, 2025, 7:46 p.m. OK C++17 (GCC 7-32) TESTS 26 218 15462400
346539689 Howsofast F Oct. 29, 2025, 10:21 p.m. OK C++17 (GCC 7-32) TESTS 26 218 15564800
346398942 minivilles F Oct. 29, 2025, 2:08 a.m. OK C++17 (GCC 7-32) TESTS 26 218 15564800
346400089 malan_c F Oct. 29, 2025, 2:28 a.m. OK C++17 (GCC 7-32) TESTS 26 218 18534400
346537788 choudharyyashu054 F Oct. 29, 2025, 9:39 p.m. OK C++17 (GCC 7-32) TESTS 26 233 5632000
346398411 beautifullife F Oct. 29, 2025, 1:57 a.m. OK C++17 (GCC 7-32) TESTS 26 233 20275200
346558641 _andyli F Oct. 30, 2025, 3:27 a.m. OK C++20 (GCC 13-64) TESTS 26 124 37478400
346560499 gapbyam F Oct. 30, 2025, 3:50 a.m. OK C++20 (GCC 13-64) TESTS 26 140 25088000
346397444 convie F Oct. 29, 2025, 1:36 a.m. OK C++20 (GCC 13-64) TESTS 26 155 122675200
346520447 Amrmahdy F Oct. 29, 2025, 6:33 p.m. OK C++20 (GCC 13-64) TESTS 26 202 28364800
346542651 nennokrah F Oct. 29, 2025, 11:29 p.m. OK C++20 (GCC 13-64) TESTS 26 202 28672000
346541345 halley2024 F Oct. 29, 2025, 10:59 p.m. OK C++20 (GCC 13-64) TESTS 26 202 29081600
346402636 classic F Oct. 29, 2025, 3:05 a.m. OK C++20 (GCC 13-64) TESTS 26 202 34201600
346407731 m7a1g5i8k8a1r4p0 F Oct. 29, 2025, 4:16 a.m. OK C++20 (GCC 13-64) TESTS 26 203 8704000
346404145 msiad F Oct. 29, 2025, 3:28 a.m. OK C++20 (GCC 13-64) TESTS 26 203 13209600
346554086 Chizer F Oct. 30, 2025, 2:37 a.m. OK C++20 (GCC 13-64) TESTS 26 203 13414400
346508016 moudgillkomal6 F Oct. 29, 2025, 5:16 p.m. OK C++23 (GCC 14-64, msys2) TESTS 26 93 7680000
346405125 hungchi17 F Oct. 29, 2025, 3:42 a.m. OK C++23 (GCC 14-64, msys2) TESTS 26 108 29388800
346544128 CeHang F Oct. 30, 2025, midnight OK C++23 (GCC 14-64, msys2) TESTS 26 140 23449600
346407700 RoBin_No_05 F Oct. 29, 2025, 4:16 a.m. OK C++23 (GCC 14-64, msys2) TESTS 26 156 17715200
346567077 BlazeH F Oct. 30, 2025, 4:54 a.m. OK C++23 (GCC 14-64, msys2) TESTS 26 171 32870400
346526481 mosaab20111 F Oct. 29, 2025, 7:24 p.m. OK C++23 (GCC 14-64, msys2) TESTS 26 202 9523200
346538432 BackOnTrack_ F Oct. 29, 2025, 9:51 p.m. OK C++23 (GCC 14-64, msys2) TESTS 26 202 10956800
346394110 sccccc F Oct. 29, 2025, 12:12 a.m. OK C++23 (GCC 14-64, msys2) TESTS 26 202 21811200
346410934 chauhanrudra0510 F Oct. 29, 2025, 4:58 a.m. OK C++23 (GCC 14-64, msys2) TESTS 26 202 50380800
346567412 iliyian F Oct. 30, 2025, 4:58 a.m. OK C++23 (GCC 14-64, msys2) TESTS 26 203 17715200
346566863 minibin F Oct. 30, 2025, 4:51 a.m. OK Java 21 TESTS 26 296 28876800
346507145 VaHiX F Oct. 29, 2025, 5:11 p.m. OK Java 21 TESTS 26 609 70656000
346565451 minibin F Oct. 30, 2025, 4:36 a.m. OK Java 21 TESTS 26 655 67686400
346523839 GuLLu05 F Oct. 29, 2025, 7 p.m. OK Java 21 TESTS 26 764 54784000
346400828 ccj123 F Oct. 29, 2025, 2:38 a.m. OK Java 21 TESTS 26 796 64819200
346523485 vineetiwari F Oct. 29, 2025, 6:57 p.m. OK Java 21 TESTS 26 842 59596800
346547442 man-ray F Oct. 30, 2025, 1:09 a.m. OK Java 21 TESTS 26 874 59187200
346390167 WrongAnswerOnTestCase2 F Oct. 28, 2025, 10:10 p.m. OK Java 21 TESTS 26 905 85811200
346485059 keshav_.agg F Oct. 29, 2025, 3:09 p.m. OK Java 21 TESTS 26 1078 107929600
346500762 amit_roy F Oct. 29, 2025, 4:41 p.m. OK Java 21 TESTS 26 1562 88473600
346383463 Shashwata_32 F Oct. 28, 2025, 9 p.m. OK Java 8 TESTS 26 624 83251200
346559765 zihanliu F Oct. 30, 2025, 3:40 a.m. OK Java 8 TESTS 26 656 56012800
346382532 yashbansal99 F Oct. 28, 2025, 8:47 p.m. OK Java 8 TESTS 26 1186 48332800
346543708 dglima F Oct. 29, 2025, 11:51 p.m. OK Node.js TESTS 26 858 91750400
346507572 VaHiX F Oct. 29, 2025, 5:14 p.m. OK PyPy 3-64 TESTS 26 312 24576000
346411584 gardengnome F Oct. 29, 2025, 5:05 a.m. OK PyPy 3-64 TESTS 26 343 28160000
346412149 gardengnome F Oct. 29, 2025, 5:10 a.m. OK PyPy 3-64 TESTS 26 437 28160000
346397034 fatalerror F Oct. 29, 2025, 1:28 a.m. OK PyPy 3-64 TESTS 26 546 48435200
346399999 RobinFromTheHood F Oct. 29, 2025, 2:26 a.m. OK PyPy 3-64 TESTS 26 546 53145600
346403902 Hell_guy F Oct. 29, 2025, 3:23 a.m. OK PyPy 3-64 TESTS 26 562 55705600
346383323 Polynomu F Oct. 28, 2025, 8:58 p.m. OK PyPy 3-64 TESTS 26 671 48947200
346409655 helltractor F Oct. 29, 2025, 4:41 a.m. OK PyPy 3-64 TESTS 26 687 128409600
346398200 fuyo1622 F Oct. 29, 2025, 1:53 a.m. OK PyPy 3-64 TESTS 26 733 54374400
346408451 wangzifan F Oct. 29, 2025, 4:26 a.m. OK PyPy 3-64 TESTS 26 780 51507200
346500990 isa773 F Oct. 29, 2025, 4:42 p.m. OK Python 3 TESTS 26 671 71270400
346538646 SpeedySebas F Oct. 29, 2025, 9:55 p.m. OK Python 3 TESTS 26 687 58368000
346502368 tequila_sunrise F Oct. 29, 2025, 4:50 p.m. OK Python 3 TESTS 26 889 84992000
346383120 jubayeddipu F Oct. 28, 2025, 8:55 p.m. OK Python 3 TESTS 26 905 49152000
346507035 iwonit F Oct. 29, 2025, 5:11 p.m. OK Python 3 TESTS 26 937 75059200
346495585 JayanthKonanki F Oct. 29, 2025, 4:11 p.m. OK Python 3 TESTS 26 1062 83148800
346409137 BikashJha F Oct. 29, 2025, 4:34 a.m. OK Python 3 TESTS 26 1108 43827200
346492576 vyshnavi_dumpala_8 F Oct. 29, 2025, 3:53 p.m. OK Python 3 TESTS 26 1109 45875200
346382583 luciferstern F Oct. 28, 2025, 8:47 p.m. OK Python 3 TESTS 26 1671 196300800

remove filters

Back to search problems