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
( 61 ) G Good Robot Paths PROGRAMMING *special data structures geometry sortings

On a Cartesian plane, there are (n) distinct points painted black, while all other points are painted white. Each black point has integer coordinates. There is also a robot that can move one unit in any of the directions ' U ' (up), ' D ' (down), ' L ' (left), or ' R ' (right) with a single command. A path of the robot from point (p_{1}) to point (p_{2}) is a sequence of commands such that if the robot, starting at point (p_{1}), executes this sequence, it will arrive at point (p_{2}). The shortest path of the robot from point (p_{1}) to point (p_{2}) is a path whose sequence consists of the minimum possible number of commands. You need to count the number of pairs of points (p_i), (p_j) ((i \neq j)) such that for this pair of points the following condition holds: All points with integer coordinates on any shortest path of the robot from point (p_{i}) to point (p_{j}) are painted black. Each test contains multiple test cases. The first line contains the number of test cases (t) ((1 \le t \le 10^4)). The description of the test cases follows. The first line of each test case contains a single integer (n) ((1 \le n \le 5 \cdot 10^{5})) — the number of points painted black. The next (n) lines of each test case contain two integers (x_{i}, y_{i}) ((-10^{9} \le x_{i}, y_{i} \le 10^{9})) — the coordinates of point (p_{i}). All points are pairwise distinct. It is guaranteed that the sum of (n) across all test cases does not exceed (5 \cdot 10^{5}). For each test case, output a single integer — the answer to the problem. In the first test case, there are (16) suitable pairs of points: (p_{1}, p_{2}) (p_{1}, p_{3}) (p_{1}, p_{4}) (p_{1}, p_{5}) (p_{2}, p_{1}) (p_{2}, p_{3}) (p_{2}, p_{4}) (p_{2}, p_{5}) (p_{3}, p_{1}) (p_{3}, p_{2}) (p_{3}, p_{4}) (p_{4}, p_{1}) (p_{4}, p_{2}) (p_{4}, p_{3}) (p_{5}, p_{1}) $$$p_{5},

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
338274807 maspy G Sept. 12, 2025, 9:50 p.m. OK Kotlin 1.7 TESTS 31 2718 317849600
338245572 abc864197532 G Sept. 12, 2025, 4:46 p.m. OK Kotlin 1.7 TESTS 31 2874 339148800
338275943 VaHiX G Sept. 12, 2025, 10:14 p.m. OK Kotlin 1.7 TESTS 31 2906 307712000
338240952 potato167 G Sept. 12, 2025, 4:14 p.m. OK Kotlin 1.7 TESTS 31 4140 263782400
338244226 Khalid_Kamal_ G Sept. 12, 2025, 4:37 p.m. OK Kotlin 1.7 TESTS 31 4421 377651200
338240283 WiwiHo G Sept. 12, 2025, 4:09 p.m. OK Kotlin 1.7 TESTS 31 4499 329728000
338247218 baluteshih G Sept. 12, 2025, 4:59 p.m. OK Kotlin 1.7 TESTS 31 4671 405913600
338246657 Ra16bit G Sept. 12, 2025, 4:54 p.m. OK Kotlin 1.7 TESTS 31 4702 389017600
338250109 Potassium G Sept. 12, 2025, 5:22 p.m. OK Kotlin 1.7 TESTS 31 4780 454451200
338244980 ppavankumarofficial G Sept. 12, 2025, 4:42 p.m. OK Kotlin 1.7 TESTS 31 4874 411033600
338246605 errorgorn G Sept. 12, 2025, 4:54 p.m. OK Kotlin 1.9 TESTS 31 2062 120320000
338239384 arvindf232 G Sept. 12, 2025, 4:03 p.m. OK Kotlin 1.9 TESTS 31 3780 105472000
338231612 tourist G Sept. 12, 2025, 3:15 p.m. OK Kotlin 1.9 TESTS 31 3905 94515200
338240039 wxhtzdy G Sept. 12, 2025, 4:08 p.m. OK Kotlin 1.9 TESTS 31 3905 179302400
338244467 OpGm G Sept. 12, 2025, 4:38 p.m. OK Kotlin 2.2 TESTS 31 671 15974400
338239284 bribritt G Sept. 12, 2025, 4:03 p.m. OK Kotlin 2.2 TESTS 31 1437 23961600
338239108 pyromon G Sept. 12, 2025, 4:01 p.m. OK Kotlin 2.2 TESTS 31 1578 162406400
338251789 furry G Sept. 12, 2025, 5:36 p.m. OK Kotlin 2.2 TESTS 31 1593 19456000
338247722 sahasrad G Sept. 12, 2025, 5:02 p.m. OK Kotlin 2.2 TESTS 31 2218 145920000
338246296 O3_Tester G Sept. 12, 2025, 4:52 p.m. OK Kotlin 2.2 TESTS 31 2624 203571200
338245352 natsugiri G Sept. 12, 2025, 4:45 p.m. OK Kotlin 2.2 TESTS 31 2921 36147200
338273734 cjtoribio G Sept. 12, 2025, 9:33 p.m. OK Kotlin 2.2 TESTS 31 3031 198246400
338237380 NetSpeed1 G Sept. 12, 2025, 3:50 p.m. OK Kotlin 2.2 TESTS 31 3124 130048000
338260150 __baozii__ G Sept. 12, 2025, 6:48 p.m. OK Kotlin 2.2 TESTS 31 3531 94720000

remove filters

Back to search problems