Hey How to solve problem B and D ? https://code.google.com/codejam/contest/6274486/dashboard#s=p1 https://code.google.com/codejam/contest/6274486/dashboard#s=p3
# | User | Rating |
---|---|---|
1 | tourist | 3985 |
2 | jiangly | 3814 |
3 | jqdai0815 | 3682 |
4 | Benq | 3529 |
5 | orzdevinwang | 3526 |
6 | ksun48 | 3517 |
7 | Radewoosh | 3410 |
8 | hos.lyric | 3399 |
9 | ecnerwala | 3392 |
9 | Um_nik | 3392 |
# | User | Contrib. |
---|---|---|
1 | cry | 169 |
2 | maomao90 | 162 |
2 | Um_nik | 162 |
4 | atcoder_official | 161 |
5 | djm03178 | 158 |
6 | -is-this-fft- | 157 |
7 | adamant | 155 |
8 | awoo | 154 |
8 | Dominater069 | 154 |
10 | luogu_official | 150 |
Hey How to solve problem B and D ? https://code.google.com/codejam/contest/6274486/dashboard#s=p1 https://code.google.com/codejam/contest/6274486/dashboard#s=p3
Name |
---|
Auto comment: topic has been updated by sanket407 (previous revision, new revision, compare).
For B, calculate dp[i][j], which denotes the size of maximum square ending at i,j. Then simply sum dp[i][[j] from i=0 to R-1 and j=0 to C-1. Calculating the above dp is explained here: http://www.geeksforgeeks.org/maximum-size-sub-matrix-with-all-1s-in-a-binary-matrix/
Thanks :>> problem D any idea ?
In problem A test case 2 , how is the probability of transition from (8,3)->(8,2) = 0.23743359 . Can anyone please explain this.
0.6121*(1-0.6121). You visit (8,2) twice.
Thanks for the explanation
D:
O(n**3) solution is to compress the given values in both column so none of them goes over n.
Then if you are at state (i, j) (i is the maximum attack value and j is the maximum defence value in the already choosen set), you could try out all possible pair (soldier) you could add in O(n) and then memoize the results. This only passes small test though.
The solution to problem D is actually deceptively simple. Let's say whoever picks last wins.
If there are no soldiers, then Alice loses, because she has no moves. Otherwise, let the highest attack of the soldiers be maxA and the highest defense be maxD. We have two cases:
The straightforward O(n2) implementation is good enough, but it should be possible to implement this in by sorting the soldiers first.
You are so smart!