hsingh1011's blog

By hsingh1011, history, 8 years ago, In English

my code of problem c is misjudged and given wrong answer but on different compilers it is giving right answer. My rating has been decreased. Submission link: **https://codeforces.me/contest/1111/submission/49432400** contest link: **https://codeforces.me/contest/1111**

  • Vote: I like it
  • -12
  • Vote: I do not like it

»
8 years ago, hide # |
 
Vote: I like it +1 Vote: I do not like it

There is at least one mistake in your code, on line 90

sort(ar,ar+n);

This should be

sort(ar,ar+k);

because the array has k elements, not n. And accessing elements outside the array is undefined behavior, so the codeforces compiler is probably ok.

»
8 years ago, hide # |
 
Vote: I like it +1 Vote: I do not like it

welcome to undefined behaviour world

»
8 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

The results given by your program differ, depending on the compilation flags. Compiler on CF used different settings than you on your own computer. The problem occurs because you've got technical mistakes in your code. I don't know which one exactly caused that but for example you've got 'dfs' function that is int type but returns nothing.