Kotlin Heroes: Episode 13

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
2141 Kotlin Heroes: Episode 13 FINISHED False 9000 18717923 Sept. 12, 2025, 2:35 p.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 55 ) I Color the Tree PROGRAMMING *special

You are given a tree consisting of (n) vertices. Initially, none of the vertices of the tree are colored. You can perform the following operation: choose any two vertices (u) and (v) (you are allowed to choose (u=v)) and color all the vertices on the path between them (including the endpoints) with color (i), where (i) is the index of the operation you are performing (that is, the first operation uses color (1), the second uses color (2), and so on). If any vertex on the path has already been colored before, its color changes to the new one. We call the coloring of the tree complete if for each vertex, at least one operation has colored it. Your task is to calculate two values: the minimum number of operations required to achieve a complete coloring; the number of distinct complete colorings that can be obtained with the minimum number of operations (two colorings are considered different if there exists at least one vertex (v) such that the color of (v) in the first coloring differs from the color of (v) in the second coloring). The first line contains a single integer (n) ((3 \le n \le 32)) — the number of vertices in the tree. The next ((n-1)) lines contain two integers (x_i) and (y_i) ((1 \le x_i, y_i \le n); (x_i \ne y_i)) — the endpoints of the next edge of the tree. Additional constraint on the input: the edges define a valid tree with (n) vertices. Print two integers — the minimum number of operations and the number of distinct complete colorings that can be obtained with the minimum number of operations. Since the second number can be very large, output it modulo (998244353).

Tutorials

Kotlin Heroes 13 Editorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
338299358 choudharyyashu054 I Sept. 13, 2025, 5:33 a.m. OK Kotlin 1.7 TESTS 94 2406 143155200
338259683 Movazed I Sept. 12, 2025, 6:43 p.m. OK Kotlin 1.9 TESTS 94 3093 18124800
338242669 tourist I Sept. 12, 2025, 4:25 p.m. OK Kotlin 1.9 TESTS 94 3093 18124800

remove filters

Back to search problems