Le_Gusto's blog

By Le_Gusto, history, 10 months ago, In English

After solving Leetcode all day long on Valentine's day ( :( ), it was finally time to test what I learned.

Unfortunately, I wasn't able to help Sasha ask out his crush. In fact, the farthest I got was solving problem A, which took barely any time, but then none of my solutions worked for B and C. I honestly have no idea what went wrong with problem B (Sasha and the Drawing) — I couldn't pass the second pretest, so I started sketching many squares, from 8x8 to 2x2, and looked for any patterns I missed, but it seemed like the program worked correctly for any testcase I could think of. I was pretty bummed out after sketching for around an hour and still failing pretest 2, so I decided to try problem C (Sasha and the Casino). I noticed that there was something going on with the sum of all previous coins and reached the conclusion that each winning bet has to make more than all the previous losses and the current bet combined, but the algorithm I came up with was too slow. I tried making it faster by calculating how many times Sasha will bet the same number of coins before the winnings become too small, but I couldn't get it to work correctly on bigger test cases. In the end, I was left with only one problem solved, which kinda sucks, but at least I know what I need to work at.

Overall, I felt like the contest was alright — the theme was nice and it didn't feel like I couldn't solve the questions because they were confusing or anything. I think I have a big hole in math/combinatorics problems, because it seems like the answers for lower rated problems that I can't solve usually don't involve hard algorithms, just some detail that I couldn't find. Maybe it might be a good idea to check out higher difficulty questions too during contests, cause I know a couple of graph algorithms and some DP. I'll be looking forward to the editorial though.

'til the next contest!

  • Vote: I like it
  • +11
  • Vote: I do not like it