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

February 11, 2020 ยท View on GitHub

Python solutions of Facebook Hacker Cup 2018. 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
1TouristPythonO(K)O(1)EasyMath
2InterceptionPythonO(1)O(1)EasyMath
3Ethan Searches for a StringPythonO(N)O(1)EasyString

Round 1

#TitleSolutionTimeSpaceDifficultyTagNote
1Let It FlowPythonO(N)O(W)EasyDP
2Ethan Traverses a TreePythonO(N)O(N)EasyGraph
3Platform ParkourPythonO(N * (M + logZ))O(N)MediumIntervals
4Evening of the Living DeadPythonO(N * M)O(N)HardDP, Probability

Round 2

#TitleSolutionTimeSpaceDifficultyTagNote
1Ethan Finds the Shortest PathPythonO(N)O(1)EasyGraph, Greedy
2Jack's Candy ShopPythonO(N * (logN)^2)O(N)MediumGreedy, Heap, Stack, Recursion
3Replay ValuePyPyO(N^5)O(N^4)HardDP
4Fossil FuelsPyPyO(NlogN)O(N)HardDP, Mono Deque, Segment Tree, RMQ

Round 3

#TitleSolutionTimeSpaceDifficultyTagNote
1Jammin'PythonO(N)O(1)EasySimulation
2Ethan Finds the Maximum Subarray SumPythonO(M^2 * K)O(1)MediumGreedy
3Graph GiftPyPyO(N^2)O(N)MediumGreedy
4FinshakesPythonO(M^3)O(M^2)HardDP

Final Round

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

#TitleSolutionTimeSpaceDifficultyTagNote
1Contest EnvironmentPythonO(N)O(1)EasyMath
2StockholmPythonO(logA + logB)O(logA + logB)EasyBinary Tree, Bit Manipulation, Greedy
3Ethan Sums Shortest DistancesPython
Python
Python
Python
O(N^3)O(N^2)EasyPrefix Sum, DP
4Personal SpacePyPyO(NlogN)O(N)MediumSkip List, Line Sweep, DP
5City LightsPyPy PyPyO(S^2 * W^2)O(S * W * min(S, W))HardSkip List, Binary Search, Recursion, Prefix Sum, DP
6The ClawPythonO(NlogN)O(N)MediumMono Stack, Binary Search, Segment Tree, DP