MetaHackerCup-2024 [](./LICENSE)

January 7, 2026 ยท View on GitHub

  • Python3 solutions of Meta Hacker Cup 2024. Solution begins with * means it will get TLE in the largest data set.
  • Total computation amount > 10^8, which is not friendly for Python3 to solve in 5 ~ 15 seconds. A 6-minute timer is set for uploading the result this year.
  • A problem was marked as Very Hard means that it was an unsolved one during the contest and may not be that difficult.

Rounds

Practice Round

#TitleSolutionTimeSpaceDifficultyTagNote
AWalk the LinePython3O(1)O(1)EasyGreedy
BLine by LinePython3O(1)O(1)EasyMath
CFall in LinePython3O(K * N)O(1)MediumRandomized Algorithm
D1Line of Delivery (Part 1)Python3O(NlogN)O(1)MediumSort
D2Line of Delivery (Part 2)Python3O(NlogN)O(1)HardSort

Round 1

#TitleSolutionTimeSpaceDifficultyTagNote
ASubsonic SubwayPython3O(N)O(1)EasyMath
BPrime SubtractorizationPython3precompute: O(MAX_N)
runtime: O(1)
O(MAX_N)MediumNumber Theory, Linear Sieve of Eratosthenes, DP
CSubstantial LossesPython3O(1)O(1)MediumExpected Value
DSubstitution CipherPython3O(N)O(1)HardGreedy, DP
EWildcard SubmissionsPyPy3O(N * L * S)O(L * S)HardDP, Inclusion-Exclusion Principle

Round 2

#TitleSolutionTimeSpaceDifficultyTagNote
A1Cottontail Climb (Part 1)Python3O(285)O(45)EasyPrecomputation
A2Cottontail Climb (Part 2)PyPy3precompute: O(17 * 73025424)
runtime: O(73025424)
O(73025424)EasyPrecomputation, Backtracking
BFour in a BurrowPyPy3O((R * C) * (R + 1)^C)O(C * (R + 1)^C)MediumBFS
CBunny HopscotchPyPy3O((R * C * log(min(R, C))) * log(max(R, C)))O(R * C)MediumBinary Search, Two Pointers, Sliding Window, BIT, Fenwick Tree
DSplitting HaresPython3O(N + MAX_W^2)O(N + MAX_W)HardGreedy, DP, Backtracing

Round 3

#TitleSolutionTimeSpaceDifficultyTagNote
ASet, CoverPython3O(N^2)O(N)EasyArray
BLeast Common AncestorPython3O(N * (logN)^2)O(N)EasySort, DFS, Sorted List, Freq Table, Small-to-Large Merging
CCoin ChangePython3O(min(N, THRESHOLD))O(1)HardExpected Value, Harmonic Series, Euler's Constant
DMin-flow Max-cutPython3O(N * logN * logM)O(N)HardDFS, Treap, Prefix Sum, Small-to-Large Merging
E1All Triplets Shortest Path (Part 1)Python3O(N)O(N)MediumGraph, Floyd-Warshall Algorithm
E2All Triplets Shortest Path (Part 2)Python3O(N)O(N)MediumGraph, Floyd-Warshall Algorithm

Final Round

You can relive the magic of the 2024 Hacker Cup World Finals by watching the Live Stream Recording of the announcement of winners.

#TitleSolutionTimeSpaceDifficultyTagNote
ADuplicate OrderPython3O(N + min(M1, M2) + H^2)O(N + min(M1, M2) + H)EasyCombinatorics, Prefix Sum, Fast Exponentiation
BDistributed ServerPython3O((R + C)^2 * (R * C)^3)O(R * C)EasyBinary Search, Max Flow, Dinic's Algorithm
CChicken TenderPython3O(N^2 * logR)O(N)MediumTernary Search, Geometry
DSushi PlatterPython3O(N^3 * MAX_A + M! * ((M - 1) * 2^(M - 1)))O(N^2 * MAX_A)MediumConnected Component DP, Prefix Sum, Permutation, Bitmasks
ESnake CoverPython3O(M)O(M)MediumSimulation, Data Structures, Queue, Mono Deque
FPizza BroilerPython3O(W + NlogW)O(W)HardGeometry, Binary Search, Prefix Sum, Count Lattices