GoogleKickStart 2021 [](./LICENSE)

March 20, 2022 ยท View on GitHub

  • Python solutions of Google Kick Start 2021. Solution begins with * means it will get TLE in the largest data set.
  • Total computation amount > 10^8 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.
  • From 2021-04, PyPy3 is supported by the online judge.
  • From 2021-11, Python2/PyPy2 is no longer supported by the online judge.
  • You need to run 2to3 -n -W --add-suffix=3 solution.py to convert the solution into Python3/PyPy3.

Rounds

Round A

#TitleSolutionTimeSpaceDifficultyTagNote
AK-Goodness StringPythonO(N)O(1)EasyString
BL Shaped PlotsPythonO(R * C)O(min(R, C))EasyDP
CRabbit HousePythonO(R * C)O(R * C)MediumBucket Sort, BFS
DChecksumPythonO(N^2)O(N^2)HardMST, Prim's Algorithm

Round B

#TitleSolutionTimeSpaceDifficultyTagNote
AIncreasing SubstringPythonO(N)O(1)EasyString
BLongest ProgressionPython PythonO(N)O(1)MediumDP
CConsecutive PrimesPythonO(N^(1/4) * MAX_GAP)O(1)MediumMath, Prime Gap
DTruck DeliveryPyPyO((N + Q) * (logN + log(MAX_A)))O(N)HardDFS, Segment Tree

Round C

#TitleSolutionTimeSpaceDifficultyTagNote
ASmaller StringsPythonO(N)O(1)EasyMath, Counting
BAlien GeneratorPythonO(sqrt(G))O(1)EasyMath, Arithmetic Progression
CRock Paper ScissorsPython PythonO(N)O(1)MediumMath, Expected Value, DP, Backtracing, Precompute
DBinary OperatorPython Python PythonO(N * E)O(N * E)HardMath, Polynomial Calculator, Hash

Round D

#TitleSolutionTimeSpaceDifficultyTagNote
AArithmetic SquarePythonO(1)O(1)EasyMath, Counting
BCutting IntervalsPythonO(NlogN)O(N)MediumLine Sweep, Greedy
CFinal ExamPyPy PyPyO(NlogN + M * log(N + M))O(N + M)MediumSkip List, Sorted List, Binary Search
DPrimes and QueriesPython PythonO(N * (logN + log(log(MAX_A))) + Q * (logN + log(log(MAX_VAL)) + log(log(MAX_S))))O(N)HardBIT, Fenwick Tree, LTE, Lifting The Exponent Lemma, Binary Search

Round E

#TitleSolutionTimeSpaceDifficultyTagNote
AShuffled AnagramsPythonO(N)O(N)EasyString, Grouping
BBirthday CakePythonO(1)O(1)HardMath, Greedy
CPalindromic CrosswordPython Python PythonO(N * M)O(N * M)EasyGraph, BFS, DFS, Union Find
DIncreasing Sequence Card GamePythonprecompute: O(EPS^(-1))
runtime: O(1)
O(EPS^(-1))MediumMath, Expected Value, Harmonic Series, DP, Precompute, Series Estimation with Integrals

Round F

#TitleSolutionTimeSpaceDifficultyTagNote
ATrash BinsPythonO(N)O(N)EasyDP
BFestivalPython PyPy Python PythonO(NlogN)O(N)EasyLine Sweep, BIT, Fenwick Tree, Skip List, Sorted List, Heap
CStar TrappersPyPy PythonO(N^3)O(1)MediumMath, Geometry
DGraph TravelPythonO(M + N * 2^N)O(2^N)MediumDP, Bitmask

Round G

#TitleSolutionTimeSpaceDifficultyTagNote
ADogs and CatsPython PythonO(N)O(1)EasySimulation
BStaying HydratedPython Python PythonO(K) on averageO(K)EasyPrefix Sum, Binary Search, Math, Median, Quick Select
CBanana BunchesPyPyO(N^2)O(min(N^2, K))MediumTwo Pointers, DP
DSimple PolygonPython PythonO(N)O(1)HardMath, Pick's Theorem, Constructive Algorithms

Round H

#TitleSolutionTimeSpaceDifficultyTagNote
ATransform the StringPython PythonO(N)O(1)EasyString
BPainterPython PythonO(N)O(1)EasyGreedy
CSilly SubstitutionsPython PythonO(N)O(N)MediumSimulation, Linked List
DDependent EventsPython Python PythonO(NlogN + QlogN)O(NlogN)HardEuler's Theorem, Fermat's Little Theorem, Probability, DFS, LCA, Tree Ancestors (Binary Lifting), Tarjan's Offline LCA Algorithm, DP