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 19063488 Sept. 12, 2025, 2:35 p.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 83 ) H Merging Vertices in a Graph PROGRAMMING *special dfs and similar dsu graphs

You are given an undirected graph, initially containing (n) vertices and (m) edges. You can perform the following operation on this graph: Choose any two distinct vertices of the graph, remove them, and insert a new vertex that is connected by edges to all vertices that were connected to both of the chosen vertices. That is, if the chosen vertices are (u) and (v), and the new vertex is (x), then edges ((x, y)) are added to the graph for all such vertices (y) that both edges ((u, y)) and ((v, y)) existed before the operation. This operation can be performed any number of times until there exists a vertex in the graph that is directly connected by edges to all other vertices. As soon as such a vertex appears, the process ends. Additionally, if such a vertex already exists in the graph initially, no operations can be performed. Your task is to count the minimum and maximum number of operations that you can perform. The first line contains two integers (n) and (m) ((1 \le n \le 2 \cdot 10^5); (0 \le m \le \min(\frac{n(n - 1)}{2}, 2 \cdot 10^5))). The (i)-th of the following (m) lines contains two integers (x_i, y_i) ((1 \le x_i, y_i \le n); (x_i \ne y_i)) — the endpoints of the (i)-th edge. There is at most one edge between each pair of vertices. Output two integers — the minimum and the maximum number of operations. In the first example, the shortest sequence of operations is as follows: Choose vertices (1) and (3), then the resulting vertex will be connected to vertices (2), (4), (5), and there are no other vertices in the graph. The longest sequence of operations is as follows: Choose vertices (1) and (5). Let the resulting vertex be (6); it will not be connected to any of the remaining vertices. Choose vertices (2) and (4). Let the resulting vertex be (7); it will be connected to vertex (3). Choose vertices (7) and (3). Let th

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
338275976 VaHiX H Sept. 12, 2025, 10:15 p.m. OK Kotlin 1.7 TESTS 88 374 19865600
338246936 sabhinsv H Sept. 12, 2025, 4:57 p.m. OK Kotlin 1.7 TESTS 88 374 19865600
338247841 sunnydev H Sept. 12, 2025, 5:03 p.m. OK Kotlin 1.7 TESTS 88 421 43315200
338269376 andrei_C1 H Sept. 12, 2025, 8:30 p.m. OK Kotlin 1.7 TESTS 88 640 104448000
338245494 yarasikavitha H Sept. 12, 2025, 4:46 p.m. OK Kotlin 1.7 TESTS 88 655 87347200
338276222 maspy H Sept. 12, 2025, 10:20 p.m. OK Kotlin 1.7 TESTS 88 921 222924800
338241974 ppavankumarofficial H Sept. 12, 2025, 4:20 p.m. OK Kotlin 1.7 TESTS 88 1077 286105600
338252529 Fysty H Sept. 12, 2025, 5:42 p.m. OK Kotlin 1.7 TESTS 88 1077 302080000
338242905 baluteshih H Sept. 12, 2025, 4:27 p.m. OK Kotlin 1.7 TESTS 88 1187 301670400
338239890 jekota8843 H Sept. 12, 2025, 4:07 p.m. OK Kotlin 1.7 TESTS 88 1343 318259200
338246283 Iplay1.d4 H Sept. 12, 2025, 4:52 p.m. OK Kotlin 1.9 TESTS 88 515 40960000
338242141 MohamedSaeed H Sept. 12, 2025, 4:22 p.m. OK Kotlin 1.9 TESTS 88 531 49561600
338241484 errorgorn H Sept. 12, 2025, 4:17 p.m. OK Kotlin 1.9 TESTS 88 593 36147200
338235061 arvindf232 H Sept. 12, 2025, 3:35 p.m. OK Kotlin 1.9 TESTS 88 702 40652800
338233017 tourist H Sept. 12, 2025, 3:24 p.m. OK Kotlin 1.9 TESTS 88 843 33177600
338263593 ivatopuria H Sept. 12, 2025, 7:25 p.m. OK Kotlin 1.9 TESTS 88 952 87244800
338240467 Ashar-Usmani H Sept. 12, 2025, 4:11 p.m. OK Kotlin 1.9 TESTS 88 968 77721600
338246794 ivatopuria H Sept. 12, 2025, 4:56 p.m. OK Kotlin 1.9 TESTS 88 983 70963200
338264052 ivatopuria H Sept. 12, 2025, 7:30 p.m. OK Kotlin 1.9 TESTS 88 1155 40550400
338249157 shevlopmes H Sept. 12, 2025, 5:14 p.m. OK Kotlin 1.9 TESTS 88 1405 79360000
338247250 zabojeb H Sept. 12, 2025, 4:59 p.m. OK Kotlin 2.2 TESTS 88 374 2867200
338247406 emthrm H Sept. 12, 2025, 5 p.m. OK Kotlin 2.2 TESTS 88 421 4096000
338242677 pyromon H Sept. 12, 2025, 4:25 p.m. OK Kotlin 2.2 TESTS 88 436 40345600
338247780 _raaghav_22 H Sept. 12, 2025, 5:03 p.m. OK Kotlin 2.2 TESTS 88 499 34099200
338243016 abhaykumar70953 H Sept. 12, 2025, 4:28 p.m. OK Kotlin 2.2 TESTS 88 530 41472000
338229136 OpGm H Sept. 12, 2025, 3:02 p.m. OK Kotlin 2.2 TESTS 88 562 32563200
338242535 __baozii__ H Sept. 12, 2025, 4:24 p.m. OK Kotlin 2.2 TESTS 88 593 35123200
338283886 binminh01 H Sept. 13, 2025, 1:33 a.m. OK Kotlin 2.2 TESTS 88 608 34099200
338237101 Egor H Sept. 12, 2025, 3:48 p.m. OK Kotlin 2.2 TESTS 88 640 32256000
338246991 bindpankaj H Sept. 12, 2025, 4:57 p.m. OK Kotlin 2.2 TESTS 88 656 36352000

remove filters

Back to search problems