-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
shixi_chenzhang
committed
Apr 24, 2017
1 parent
c1f6a3a
commit 8f1e11e
Showing
30 changed files
with
249 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# APAC 2016 Practice Round | ||
https://code.google.com/codejam/contest/6234486/dashboard | ||
|
||
## Problem A: Bad Horse | ||
|
||
BFS/DFS to mark color for each horse. Simple. | ||
|
||
## Problem B: Captain Hammer | ||
|
||
`t=d/v_x=2*v_y/g, ¦È=arcsin(gd/v^2)/2` | ||
|
||
## Problem C: Moist | ||
|
||
Simple. Keep the current max value. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# APAC 2016 Round A | ||
https://code.google.com/codejam/contest/4284486/dashboard | ||
|
||
## Problem A: Googol String | ||
|
||
Simple. Nothin to tell. | ||
|
||
## Problem B: gCube | ||
|
||
Simple. `V=PI_(i,l,r) {a[i]}, Edge=pow(V, 1/d).` | ||
|
||
## Problem C: gCampus | ||
|
||
Floyd to calculate the distance of any two offices. | ||
Then, for each road, if the distance between its two verticals is smaller than | ||
its length, then it's an inefficient road. | ||
|
||
## Problem D: gSnake | ||
|
||
Brute force. As X<=1000000, we can simulate at most 1100000 seconds. | ||
for every second in [1, 1100000], check if the snake will die, or it can eat food. | ||
Using HashSet to remember all bodies, and all foods eaten. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# APAC 2016 Round B | ||
https://code.google.com/codejam/contest/10214486/dashboard | ||
|
||
## Problem A: Travel | ||
|
||
As `Cost[t] ¡Ü Cost[t+1]+1`, we cannot stop at any city. | ||
So, just for each start time, bfs to find the minimal time. | ||
|
||
## Problem B: gWheels | ||
|
||
As `p/e*e'/t=P/Q`, we can calculate all possible `e/e'` in the extra | ||
gears. Then, for each p in Np and t in Nt, check if Pt/pQ is possible. | ||
|
||
## Problem C: gNumbers | ||
|
||
Calculate all factors of n with only one prime. `9075=3*25*121, etc.` | ||
Then dfs with memorization to solve it! | ||
|
||
## Problem D: Albocede DNA | ||
|
||
It's a really, really difficult problem. | ||
DP, dp[i][j][k][l] where i means the current character, j means | ||
the number of a, k means the number of b, and l means if we have | ||
started to deal with c/d. | ||
Check [D.java](D.java) for more details. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# APAC 2016 Round C | ||
https://code.google.com/codejam/contest/4284487/dashboard | ||
|
||
## Problem A: gRanks | ||
|
||
Brute force. Simple. | ||
|
||
## Problem B: gFiles | ||
|
||
Intervals intersection. | ||
Take care of p=0 and p=100. Use `long` instead of `double`. | ||
|
||
## Problem C: gGames | ||
|
||
DP/DFS with memorization. | ||
dp[i][x] means, can we put x in first i rounds. Here x records people | ||
(one in a bit). | ||
To solve this, just break x into two numbers y and z, then check dp[i-1][y] | ||
and dp[i-1][z]. Check all possible subsets. | ||
Return `dp[n][(1<<n)-1]`. | ||
|
||
## Problem D: gMatrix | ||
|
||
First, solve the problem [Sliding Window Maximum](https://leetcode.com/problems/sliding-window-maximum/). | ||
Then, just apply it to each row, then each col. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# APAC 2016 Round D | ||
https://code.google.com/codejam/contest/11214486/dashboard | ||
|
||
## Problem A: Dynamic Grid | ||
|
||
Simple problem. | ||
For each query, just bfs is enough. | ||
|
||
## Problem B: gBalloon | ||
|
||
Solution #1: DP | ||
dp[i][j] means the minimal time of first i balloons with j amounts of energy. | ||
`dp[i][j]=min(max(dp[i-1][j-|h[i]-k|], |p[i]/wind[k]|)) for 1<=k<=m`. | ||
Time complexity: O(mnq)~10^9, large solved in 164.685s. | ||
|
||
Solution #2: Binary Search | ||
For each time, check if we can collect all balloons. | ||
Time complexity: O(mn*log(p_max)), large solved in 1.175s | ||
|
||
## Problem C: IP Address Summarization | ||
|
||
Trie. For each node in trie, mark if it's an end. | ||
If a node is end, remove all sub-trees of it. | ||
If the left and right children of a node are both end, then it's an end. | ||
|
||
## Problem D: Virtual Rabbit | ||
|
||
For small, just check if `[curr+1, curr+x]` has intersection with | ||
`[day_start+g, dat_start+w-1], [day_start+h, day_start+b-1], | ||
[day_start+86400+g, dat_start+86400+w-1], [day_start+86400+h, | ||
day_start+86400+b-1]`. | ||
Find the max point to be the fed time. | ||
|
||
For large, we cannot simulate in the whole process. | ||
What's to do is, find the loop. That is, find two days where | ||
Alice feed the rabbit at the same second. | ||
After finding the loop, we can just calculate how many days in a loop, | ||
how many feed times in a loop, and how many loops there are. | ||
It's hard to implement, please be careful. | ||
Check [D.java](D.java) for more details. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.