Himitsu's blog

By Himitsu, history, 6 years ago, In English

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.

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

| Write comment?
»
6 years ago, # |
  Vote: I like it +102 Vote: I do not like it

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 years ago, # ^ |
      Vote: I like it +6 Vote: I do not like it

    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 years ago, # |
Rev. 5   Vote: I like it +38 Vote: I do not like it

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 years ago, # ^ |
      Vote: I like it +3 Vote: I do not like it

    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 years ago, # |
  Vote: I like it +4 Vote: I do not like it

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 years ago, # ^ |
      Vote: I like it -35 Vote: I do not like it

    A lot of of my comments got positive votes. This is proof enough that the voting system is broken.

»
6 years ago, # |
  Vote: I like it +18 Vote: I do not like it

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.