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

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

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**

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

»
8 лет назад, скрыть # |
 
Проголосовать: нравится +1 Проголосовать: не нравится

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 лет назад, скрыть # |
 
Проголосовать: нравится +1 Проголосовать: не нравится

welcome to undefined behaviour world

»
8 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

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.