FacebookHackerCup-2019 [](https://creativecommons.org/licenses/by-nc/3.0/)

November 14, 2020 · View on GitHub

Python solutions of Facebook Hacker Cup 2019. Solution begins with * means it will get TLE in the largest data set (total computation amount > 10^8, which is not friendly for Python to solve in 5 ~ 15 seconds). A 6-minute timer is set for uploading the result this year.

Qualification Round

#TitleSolutionTimeSpaceDifficultyTagNote
1Leapfrog: Ch. 1PythonO(N)O(1)EasyMath
2Leapfrog: Ch. 2PythonO(N)O(1)EasyMath
3Mr. XPython PythonO(E)O(D)MediumString
4Trees as a ServicePythonO(N^2 * (N + M))O(N)HardRecursion

Round 1

#TitleSolutionTimeSpaceDifficultyTagNote
1Graphs as a ServicePythonO(N^3)O(N^2)EasyFloyd-Warshall Algorithm
2Class TreasurerPythonO(N)O(N)EasyGreedy
3Ladders and SnakesPythonO(N^4)O(N^2)HardLine Sweep, Dinic's Algorithm, Max-Flow Min-Cut Theorem
4Connect the DotsPythonO(NlogN)O(N)HardHeap, Sort

Round 2

#TitleSolutionTimeSpaceDifficultyTagNote
1On the RunPythonO(1)O(1)EasyMath
2Bitstrings as a ServicePythonO((M + N) * N)O(N^2)MediumUnion Find, DP
3GradingPyPyO(S * H^2)O(H)HardDP, Binary Search
4SeafoodPythonO(NlogN)O(N)HardMono Stack, Binary Search, DP

Round 3

#TitleSolutionTimeSpaceDifficultyTagNote
1Light ShowPythonO(N^2)O(N)EasyDP
2Integers as a ServicePythonO(NlogN)O(1)MediumEuclidean Algorithm, GCD, LCM
3RenovationsPythonO(NlogK)O(N)MediumProbability, Euler's Theorem
4Chain of CommandPythonO(N * (logN)^2)O(N)HardHeavy-Light Decomposition, Stack, Recursion, BIT, Fenwick Tree

Final Round

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

#TitleSolutionTimeSpaceDifficultyTagNote
1Strings as a ServicePython PythonO(KlogK)O(1)EasyGreedy
2KhajiitPythonO(N * M)O(1)EasyGreedy
3ScoreboardPythonO(N ^2* M)O(1)EasySet
4Little Boat on the SeaPyPyO(NlogN)O(NlogN)MediumPreorder Traversal (Stack), Tree Ancestors (Binary Lifting), Line Sweep, Segment Tree (Lazy Propagation), RMQ
5Cold StoragePyPyO(N^2)O(N^2)MediumDP
6Temporal RevisionPythonO((S + N) * logN + (K + M) * α(N))O(NlogN)HardUnion Find, DP, Preorder Traversal (Stack), Tree Ancestors (Binary Lifting)