Python solutions of Google Code Jam 2014. 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 4-minute
timer is set for the small dataset and a 8-minute
timer is set for the large dataset this year.
- Code Jam 2013
- Qualification Round
- Round 1A
- Round 1B
- Round 1C
- Round 2
- Round 3
- World Finals
- Code Jam 2015
# | Title | Solution | Time | Space | Difficulty | Tag | Note |
---|---|---|---|---|---|---|---|
A | Magic Trick | Python | O(1) | O(1) | Easy | Set | |
B | Cookie Clicker Alpha | Python | O(X / C) | O(1) | Easy | Math | |
C | Minesweeper Master | Python | O(R * C) | O(1) | Medium | Enumeration | |
D | Deceitful War | Python | O(NlogN) | O(N) | Medium | Sort |
# | Title | Solution | Time | Space | Difficulty | Tag | Note |
---|---|---|---|---|---|---|---|
A | Charging Chaos | Python | O(N^2) | O(N) | Easy | Bit Manipulation | |
B | Full Binary Tree | Python | O(N) | O(N) | Easy | DFS, Graph, Binary Tree | |
C | Proper Shuffle | Python | precompute: O(N^2) classify: O(N) |
O(N^2) | Medium | Precomputation, Probability, Naive Bayes Classifier |
# | Title | Solution | Time | Space | Difficulty | Tag | Note |
---|---|---|---|---|---|---|---|
A | The Repeater | Python | O(X * N) | O(X * N) | Easy | Math | |
B | New Lottery Game | Python | O(log(max(A, B))) | O(log(max(A, B))) | Medium | Math, DP, Memoization | |
C | The Bored Traveling Salesman | Python | O(N^3) | O(M + N) | Hard | Greedy |
# | Title | Solution | Time | Space | Difficulty | Tag | Note |
---|---|---|---|---|---|---|---|
A | Part Elf | Python | O(logQ) | O(1) | Easy | Math | |
B | Reordering Train Cars | Python | O(L) | O(1) | Medium | Math | |
C | Enclosure | Python | O(N^2 * M) | O(1) | Hard | Greedy, Math |
# | Title | Solution | Time | Space | Difficulty | Tag | Note |
---|---|---|---|---|---|---|---|
A | Data Packing | Python Python | O(N) | O(1) | Easy | Counting Sort, Greedy, Two Pointers | |
B | Up and Down | Python | O(NlogN) | O(N) | Easy | Greedy, BIT, Fenwick Tree | |
C | Don't Break The Nile | Python | O(B^2) | O(B) | Medium | Greedy, Minimum Cut, Dijkstra's Algorithm | |
D | Trie Sharding | Python | O(M * L + T * N^2) | O(T) | Hard | Trie, Greedy, Combinatorics, Counting, DP |
# | Title | Solution | Time | Space | Difficulty | Tag | Note |
---|---|---|---|---|---|---|---|
A | Magical, Marvelous Tour | Python | O(N) | O(N) | Easy | Two Pointers | |
B | Last Hit | Python | O(N^2 * MAX_H/Q) | O(N * MAX_H/Q) | Medium | DP | |
C | Crime House | Python | O(N^2 * logN) | O(N) | Hard | Greedy, Binary Search | |
D | Willow | Python | O(N^2) | O(N^2) | Very Hard | Game, Tree, Minimax, Memoization, Precompute, DP |
You can relive the magic of the 2014 Code Jam World Finals by watching the Live Stream Recording of the competition, problem explanations, interviews with Google and Code Jam engineers, and announcement of winners.
# | Title | Solution | Time | Space | Difficulty | Tag | Note |
---|---|---|---|---|---|---|---|
A | Checkboard Matrix | Python | O(N^2) | O(N^2) | Medium | ||
B | Power Swapper | Python | O(2^(N*2)) | O(2^N) | Medium | Recursion | |
C | Symmetric Trees | Python | O(N^3 * logN) | O(N^2) | Hard | Recursion | |
D | Paradox Sort | Python | O(N^2 * N!) | O(N) | Hard | DFS | |
E | Allergy Testing | Python Python | O((logN)^3) | O(1) | Hard | Binary Search | |
F | ARAM | Python | O(60 * N * R * G) | O(1) | Very Hard | Binary Search |