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

Автор Himitsu, история, 6 лет назад, По-английски

This post is with respect to my other blog which I asked recently (link). Summary is that in one question the output that the codeforces judge is showing is coming different from what my terminal is showing (I am using ubuntu).

Now, I want to ask: is this not a genuine question?

If this happened in contest, then there is no way I would have gotten the solution (since it is running fine on my system!). What would you have done if you were in my situation? How will you debug the program if it is running fine on your system and not on the judge?

So, my question is why the downvotes? I think I have asked a genuine question.

I have seen the error message and it says: "Diagnostics detected issues [cpp.clang++-diagnose]: C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.11.25503\include\vector:1802:11: runtime error: addition of unsigned offset to 0x12500250 overflowed to 0x1250024c"

I seriously don't understand how my program is giving overflow and even if that were the case, why is my terminal showing the correct output.

I would appreciate if someone can give my any help regarding this.

Thank You.

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

»
6 лет назад, # |
  Проголосовать: нравится +102 Проголосовать: не нравится

No, asking a genuine question is not bad. But your question is common and has been addressed before, so the downvotes might have been a message that you should search better the next time.

Regarding your problem, when this happens, it means there is a mistake in your code causing an undefined behaviour which is causing the difference in output when ran on 2 different environments. I would check for out of bound access first thing which I think might be the case in line 70 in your code when the array size is less than 2.

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

    I understand, I will be more careful in the future.

    Thank You for your input. Yes, as you said the problem was in that line.

»
6 лет назад, # |
Rev. 5   Проголосовать: нравится +38 Проголосовать: не нравится

Hey,

don't worry that much about downvotes, this problem is really often asked by newbies, so it's a way of showing that we've already seen this question before. Search more about it in Internet before asking again.

The problem is in line: for(int i=ar[ar.size()-2]+1;i<=b;i++) and when the ar.size()==1, the code refers to unlocalized memory so the numbers can get random in the compiler, while on your computer the number is equal for ex. to 0. So think of roundabout solution when you won't refer to this memory.

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

    Hello,

    Yes, I didn't check if this type of question has been asked before which is my fault.

    As you have said , the problem was in that line only. Thank You for your input :)

»
6 лет назад, # |
  Проголосовать: нравится +4 Проголосовать: не нравится

Codeforces downvotes/upvotes don't make sense at all. Some of the same comment gets downvotes while other get upvote (in the same posts, sometimes by the same person).

Some reasonable comment get downvote (like when I actually gave someone working solution and got downvote) while some shitpost get upvote (99% of my posts)

Also posts with pictures usually get upvotes unless it really sucks or is really unfunny.

»
6 лет назад, # |
  Проголосовать: нравится +18 Проголосовать: не нравится

As others have said, questions that have been asked before usually get downvotes. However, CodeForces' search feature is god awful, so it can be hard to tell what's been asked before and what hasn't. One general tip I'll say (that is useful for a lot of sites with bad search features, like Quora) is to use the filter site:codeforces.com on Google and then utilize Google's superior search feature. It tends to work pretty well.