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

August 30, 2021 ยท View on GitHub

Python solutions of Facebook Hacker Cup 2020. 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
ATravel RestrictionsPythonO(N^2)O(1)EasyTwo Pointers
BAlchemyPythonO(N)O(1)EasyMath
CTimberPythonO(NlogN)O(N)MediumDP
D1Running on Fumes - Chapter 1PythonO(N)O(M)MediumMono Deque
D2Running on Fumes - Chapter 2PythonO(NlogN)O(N)HardDFS, BFS, Segment Tree

Round 1

#TitleSolutionTimeSpaceDifficultyTagNote
A1Perimetric - Chapter 1PythonO(N)O(N)EasyMono Deque
A2Perimetric - Chapter 2PythonO(NlogN)O(N)MediumSkip List, Line Sweep
A3Perimetric - Chapter 3PyPyO(NlogN)O(N)HardSkip List, Line Sweep
BDislodging LogsPythonO(NlogN + MlogM + (M + N) * log(max(max(Q)-min(P), max(P)-min(Q))))O(N + M)EasyBinary Search, Greedy
CQuarantinePythonO(N)O(N)HardPreorder Traversal, Flood Fill, DP

Round 2

#TitleSolutionTimeSpaceDifficultyTagNote
ACa-pasta-tyPythonO(N)O(1)EasyMath
BEliminationPythonO(N^2)O(N^2)MediumMath, DP
CCircular CirclesPyPyO((N * M + E) * (logN + logM))O(N)MediumSkip List
DLog Drivin' Hirin'PythonO(N * (logN)^2 + MlogN)O(N)HardSkip List, Dynamic Convex Hull Trick

Round 3

#TitleSolutionTimeSpaceDifficultyTagNote
AChain ExplosionsPythonO(K^(1/2))O(1)EasyMath
BRailroad RenovationsPythonO(N^3)O(N * K)MediumDP, Math
CMail SecurityPyPyO((N + M) * (logN + logM)^2)O(N + M)HardBinary Search, Skip List, Greedy
DSmart CartsPyPyO(N^3)O(N)HardMath, Precompute

Final Round

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

#TitleSolutionTimeSpaceDifficultyTagNote
ACryptoconferencePythonO(NlogN)O(N)EasySkip List, Counting
BSomebody Else's ProblemPythonO(N)O(H)EasyTree Traversal, DP
CPond PrecipitationPythonO(N^5)O(N^2)MediumDP, Euler's Theorem, Expected Value
DSpider Spring*PyPy PyPy PyPyO((N + M) * logN)O(N)MediumSkip List, Segment Tree, BIT, Fenwick Tree, Counting
ETree TrainingPyPyO(N * (logN)^2)O(N)HardBinary Search, Counting
FCake-Cutting CommitteePyPyO(N^2 * logN)O(N)HardGeometry, Line Sweep, Segment Tree