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

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

I'm really stumped as to why my program outputs '3' on the test server but '4' on my computer.

I even tried to hardcode my solution to output '4' when it encounterd the test case, and that worked. But then interestingly I encounterd a very similar wrong answer in the 3rd batch of tests where my program output '4' but should have output '3'.

I find it kind of strange that in both cases it involves '3' and '4'.

This is my most recent submission: https://codeforces.com/contest/1485/submission/167766068

I'm compiling using: g++ -std=++17 -Wall

Thank you for any suggestions or ideas.

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

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

Please those who are downvoting this, tell me why. Ok? Because I normally dont post like this.

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

    put the initial value of best and lim and tmp equal to 0.

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

      @hunter_of_alts: Thanks for the advice still the same result. Last submission (after change): https://codeforces.com/contest/1485/submission/167772884

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

        submit it with C++20, Also float or double multiplication and division is inaccurate and I think that's the reason why it gets WA.

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

          @hunter_of_alts: Hey that worked! :)

          Now I just get the other wrong answer, which is then due to some other cause.

          Any idea or best practices to avoid this issue in the future?

          And why are folks downvoting this? I know this is not fun stuff and I'm a noob. But but it is not like I haven't tried to solve this or worked on the error. I just did not see any good way of debugging this.

          Thanks a bunch!

          Edit: About the float/double issue. Yes, that might be the case. I just wanted to save calc by using logarithm. Perhaps I should try a larger base than 2. Perhaps base 10.