Блог пользователя div4only

Автор div4only, история, 22 месяца назад, По-английски

I strongly rely on my "intuition". If my intuition is correct I can solve the problem very fast. Otherwise, I will fall into some solutions that seem right (but actually wrong). The worst thing is debugging takes too much time and upset me (affects other problems). It seems that I am the kind of guy that has strong "thinking inertia". Do you face a similar issue? How to improve? Would you please help me?

Take https://codeforces.me/contest/1779/submission/187786889 as an example. Is it just because I am stupid?

  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится

»
22 месяца назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Auto comment: topic has been updated by div4only (previous revision, new revision, compare).

»
22 месяца назад, # |
  Проголосовать: нравится +3 Проголосовать: не нравится

Yeah , I face a similar issue many times

»
22 месяца назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

i also did a same blunder mistake in C problem

»
22 месяца назад, # |
  Проголосовать: нравится +3 Проголосовать: не нравится

That is not correct idea, you're taking every number that makes your subarray "not okay" i.e. $$$p < 0$$$, but imagine situation like this: you took one big number, let me say $$$10^9$$$, and you have a lot of subarrays that are less than zero and are close to zero. You see my point? You could've gotten rid out of all those prefixes with just making $$$10^9$$$ into $$$-10^9$$$, yet still you're taking every number on the way. You should pick them more greedily.

Btw, debugging is sometimes quite challenging. Whenever I strongly believe in correctness my solution and it still doesn't get accepted I write naive solutions, like for this you could've written O(2^n) solution and ran it on random tests with your main solution. Surely it would've found you a test case where it mismatches

»
22 месяца назад, # |
  Проголосовать: нравится +3 Проголосовать: не нравится

Same problem in the last 2 contest problem A. "Falling into some solutions that seem right". I wrote a brute force code to find the wrong test case if after 15 mins I still couldn't solve it staring at my code and manually coming up with some cases. And that's when you know the contest is going to be disastrous when you start off problem A in this manner

  • »
    »
    22 месяца назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    Agree. On Codeforces If I am stuck on one problem the whole contest may become disastrous. And the absolute value of delta is too large, maybe -150 for a disastrous game.

»
22 месяца назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

It seems like you already know what the problem is — you rely too much on your intuition. So i know that this will be very hard to hear but you have to accept it.

The Solution
Explanation
conclusion

Good luck!

  • »
    »
    22 месяца назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    Thank you! Another problem is that I am not good at finding counterexamples to pseudo-solutions. Would you please help? Or I have to implement a random generator as Fanarill suggests?

    • »
      »
      »
      22 месяца назад, # ^ |
        Проголосовать: нравится +3 Проголосовать: не нравится

      No i would not suggest implementing random number generators, mainly because they take too long to implement.

      But for finding counterexamples to pseudo-solutions, I can't really give you much guidance but I can give you one thing.

      For my economics paper, I have 12 mark questions that ask a question like, "evaluate the statement: a higher minimum wage always benefit the economy". For this question, I have to write 2 paragraphs agreeing with the statement and 2 paragraphs disagreeing with the statement.

      However, on top of this, i have to write a conclusion stating what the answer depends on. Most of my classmates struggle with this (but i don't ;))) which is why my economics teacher gave us the advice, "look at all of the paragraphs you wrote. Is what you wrote always true? If not, then you found something that it depends on!". For example, assume that one of my paragraphs said, "minimum wage will cause job losses". Now I have to think, Is this always true? Well no, if a company is willing to make lower profit margins, then job losses will not come with a minimum wage.

      You must make the same observations with your code. Every piece of code you write will entail a piece of logic, a reason why you wrote that code. Now, all you have to think is, "is that piece of logic always true?". If it isn't true, then you found a counterexample, otherwise keep doing the same with all other lines of code.

      I hope you understood the analogy. GL!