Throughout the year, Google Code Jam hosts online Kickstart rounds to give participants the opportunity to develop their coding skills, get acquainted with Code Jam’s competition arena, and get a glimpse into the programming skills needed for a technical career at Google.
Each Kickstart round gives participants 3 hours to solve challenging, algorithmic problems developed by Google engineers. Participating is a fun way to grow your coding skills—and potentially explore opportunities at Google.
Inviting you to solve some fun and interesting problems on Sunday, July 29, 2018 05:00 UTC.
Dashboard can be accessed here during the contest. Problem analysis will be published soon after the contest.
24 hours bump!
Bump! The contest is one hour away :)
How to solve A.Candies ?
The analysis is up! You can read the analysis for problem A in https://code.google.com/codejam/contest/6364486/dashboard#s=a&a=0
I used two pointers approach for problem A. I was consistently getting Incorrect answer on small file itself. After the end of contest, I downloaded source file of other people on leaderboard and found that their output file was exactly same as my output file. Then, how can i get WA ? Can you please clarify ? Here is my Source Code
I also got lots of WAs. I strongly recommended you to write a simple solution and compare their outputs for randomly-generated data. Here are my tips: - When checking a number is odd or not, don't simply use
s[i] % 2
sinces[i]
may be negative, use(s[i] + (1LL << 32)) % 2
instead - For two pointer method, don't forget to check if the second pointer is at the left of the first pointer - Always uselong long
to avoid overflows[i] % 2 != 0
, which will be always true for odd number, since for even numbers[i] % 2 = 0
, irrespective of s[i] being positive or negative.#define int long long
since the constraints were large and involved multiplications, so just to be in a safeside. So, there's no chance of overflow.Here is a sample case and my output along with a simple implementation: https://gist.github.com/htfy96/20bccbb3facc471a091b8a6878a2dea8. Hope this may help you :D
Did you run the codes with the same input file? Because sometimes small inputs are different for two different people, As far as I remember, only the large input is the same for everybody.
You're not the first one with this problem, they just don't care about platform bugs.
I used the two pointer approach too. And as vivek_shah mentioned, I too was getting WA on the small input. I request you to help me out. Here's my source https://ideone.com/zrYSlH
The two pointer approach is not going to work. I used the two pointer approach in the contest and was able to solve for small data set but for the large one it failed. You should check the content analysis it provides the correct solution i.e using BST.