GoogleCodeJam 2020 [](./LICENSE)

May 17, 2021 · View on GitHub

Python solutions of Google Code Jam 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 problem was marked as Very Hard means that it was an unsolved one during the contest and may not be that difficult.

Qualification Round

#TitleSolutionTimeSpaceDifficultyTagNote
AVestigiumPythonO(N^2)O(N)EasyMath
BNesting DepthPythonO(N)O(1)EasyString
CParenting Partnering ReturnsPythonO(NlogN)O(1)EasyGreedy
DESAb ATAdPythonO(B^2)O(B)MediumBit Manipulation
EIndiciumPythonO(N^3 * sqrt(N))O(N)HardBipartite Matching, Greedy

Round 1A

#TitleSolutionTimeSpaceDifficultyTagNote
APattern MatchingPythonO(N * P)O(P)EasyString
BPascal WalkPythonO(logN^2)O(logN)MediumMath, Greedy, Bit Manipulation
CSquare DancePythonO(R * C)O(R * C)HardSimulation, BFS, Linked List

Round 1B

#TitleSolutionTimeSpaceDifficultyTagNote
AExpogoPython PythonO(log(|X| + |Y|))O(1)MediumVariant of PogoInvariant, Greedy
BBlindfolded BullseyePythonO(128)O(1)MediumProbability, Binary Search, Geometry
CJoin the RanksPythonO(R * S)O(1)HardOne-LinerInvariant, Sort

Round 1C

#TitleSolutionTimeSpaceDifficultyTagNote
AOverexcited FanPythonO(M)O(1)EasySimulation, Math
BOverrandomizedPythonO(L * U)O(1)EasyProbability
COversized Pancake ChoppersPyPy Python PythonO(N * DlogD)O(D * N)HardSort, Hash Table, Euclidean Algorithm, Binary Search, Greedy, Bucket, LCM

Round 2

#TitleSolutionTimeSpaceDifficultyTagNote
AIncremental House of PancakesPython PythonO(1)O(1)EasyBinary Search, Math
BSecurity UpdatePythonO(ClogC + D)O(C)MediumSort
CWormhoe in OnePythonO(N^2)O(N^2)MediumMath
DEmacs++PyPy* PyPyO(KlogK + QlogK)O(KlogK)HardTree, Lazy Construction, Middle Line, Dijkstra's Algorithm, Iterative Recursion, LCA, Prefix Sum, Tree Ancestors (Binary Lifting)

Round 3

#TitleSolutionTimeSpaceDifficultyTagNote
ANaming CompromisePythonO(C * J)O(C * J)EasyDP, Edit Distance
BThermometersPython PythonO(N^2)O(1)HardGreedy, Mirror
CPen TestingPyPy
Python
PyPy
Python
O(T * N^2 + N * S)O(N * (T + S))Hard❤️Heuristic, Memoization, Probability
DRecalculating*PyPy
C++
*PyPy
C++
O(N^2 * logN)O(N^2)Hard❤️Coordinate Rotation, Sliding Window, Rolling Hash, Rabin-Karp Algorithm, Line Sweep, Coordinate Compression, Segment Tree

Virtual World Finals

You can relive the magic of the 2020 Code Jam Virtual World Finals by watching the Live Stream Recording of the competition, problem explanations, interviews with Google and Code Jam engineers, and announcement of winners.

#TitleSolutionTimeSpaceDifficultyTagNote
APack the SlopesPyPyO(N * (logN)^2)O(N)MediumGreedy, Heavy-Light Decomposition, Stack, Recursion, Segment Tree (Lazy Propagation), RMQ
BAdjacent and ConsecutivePython Python PythonO(NlogN)O(N)Hard❤️State Compression, Math, Skip List
CHexacoin JamPyPyO(B^(D + 1) * D + N^2 * D)O(B^(D + 1) * D)Hard❤️Structure Match, Hash, Math
DMusical CordsPyPyO(NlogN + N * K) on averageO(N * K)Very Hard❤️Geometry, Trigonometric Functions, Two Pointers, Binary Search, Quick Select, Sort
EReplace AllPythonO(A^3)O(A^2)MediumFloyd-Warshall Algorithm, SCC, Bipartite Matching