MetaHackerCup-2022 [](./LICENSE)

September 26, 2023 ยท View on GitHub

  • Python3 solutions of Meta Hacker Cup 2022. 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

Qualification Round

#TitleSolutionTimeSpaceDifficultyTagNote
ASecond HandsPython3O(N)O(N)EasyGreedy
B1Second FriendPython3O(R * C)O(1)EasyConstructive Algorithms
B2Second Second FriendPython3O(R * C)O(R * C)MediumConstructive Algorithms, BFS
C1Second MeaningPython3O(N^2)O(N)EasyConstructive Algorithms
C2Second Second MeaningPython3O(NlogN)O(logN)MediumConstructive Algorithms
DSecond FlightPython3 Python3O(N + Q + M * min(sqrt(Q), N))O(N + M + Q)HardGraph, Memoization

Round 1

#TitleSolutionTimeSpaceDifficultyTagNote
A1Consecutive Cuts - Chapter 1Python3O(N)O(1)EasyConstructive Algorithms, String
A2Consecutive Cuts - Chapter 2Python3 Python3 Python3O(N)O(1)MediumConstructive Algorithms, String, KMP Algorithm, Z-Function, Rabin-Karp Algorithm, Rolling Hash
B1Watering Well - Chapter 1Python3O(N + Q + min(N * Q, MAX_A_B_X_Y^2))O(min(N + Q, MAX_A_B_X_Y))EasyMath, Freq Table
B2Watering Well - Chapter 2Python3O(N + Q)O(1)EasyMath
CLemonade LifePyPy3O(NlogN + V^2)O(N + V)HardGeometry, Convex Hull, Monotone Chain Algorithm, Graph, Dijkstra's Algorithm

Round 2

#TitleSolutionTimeSpaceDifficultyTagNote
A1Perfectly Balanced - Chapter 1Python3O(N + Q)O(N)EasyPrefix Sum
A2Perfectly Balanced - Chapter 2Python3O((N + Q) * logN)O(N)MediumHash, BIT, Fenwick Tree
BBalance SheetPython3O(NlogN + N * K)O(N * K)MediumSort, Greedy, DP
CBalance ScalePython3precompute: O(MAX_N * MAX_C)
runtime: O(N)
precompute: O(MAX_N * MAX_C)
runtime: O(1)
EasyCombinatorics, Probability
D1Work-Life Balance - Chapter 1Python3O((N + M) * logN)O(N)MediumBIT, Fenwick Tree, Greedy
D2Work-Life Balance - Chapter 2Python3O((N + M) * logN)O(N)HardBIT, Fenwick Tree, Greedy

Round 3

#TitleSolutionTimeSpaceDifficultyTagNote
AFourth PlayerPython3O(NlogN)O(N)MediumGames, Greedy
BThird TriePython3O(N * M)O(T)EasyTrie, Combinatorics
CSecond MistakePython3O(3 * L * (N + Q))O(3 * L * N)EasyRabin-Karp Algorithm, Hash Table
D1First Time - Chapter 1Python3O(M + NlogN)O(N)MediumUnordered Set
D2First Time - Chapter 2Python3O(M + NlogN)O(N)HardUnordered Set, Segment Tree, Number Theory
E1Zero Crossings - Chapter 1Python3 Python3O((N * M + Q) * log(N * M + Q))O(N * M + Q)HardOffline Solution, Geometry, Sort, Line Sweep, Treap, Sorted List, Binary Search, Tree, DFS, Hash
E2Zero Crossings - Chapter 2PyPy3O((N * M) * log(N * M) + Q * log(N * M))O((N * M) * log(N * M)HardOnline Solution, Geometry, Sort, Line Sweep, Persistent Treap, Binary Search, Tree, DFS, Hash

Final Round

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

#TitleSolutionTimeSpaceDifficultyTagNote
AML ModelingPyPy3O(MAX_X * MAX_Y * MAX_R * MIN_N + (MAX_X * MAX_Y)^2 + N)O(MAX_X * MAX_Y)MediumGeometry, Sampling
BEmerald ExhibitingPyPy3O(P * logN)O(MAX_N)MediumCombinatorics, Number Theory
CTile TransposingPyPy3 PyPy3O(M * N * log(M * N))O(M * N)HardDFS, Persistent Union Find
DAlphabet AdventuringPython3O((R^2 + log(N + Q)) * (N + Q) + Q * (R^2 + log(N + Q))* log(N + Q))O((R^2 + log(N + Q)) * (N + Q))HardTree Traversal, Tree Ancestors (Binary Lifting), Heavy-Light Decomposition, Path Compression
EHazelnut HarvestingPython3O(NlogN)O(NlogN)HardCoordinate Compression, Segment Tree, Line Sweep, Mono Stack
FCup CounterbalancingPyPy3O(N * S)O(N)Very HardGeometry, Sampling