Пожалуйста, подпишитесь на официальный канал Codeforces в Telegram по ссылке https://t.me/codeforces_official. ×

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

Автор ABIR, история, 4 года назад, По-английски

Please help me to understand that why my code gives wrong answer in test case 4? where in ideone or codeblocks gives right answer. ideone : https://ideone.com/1YmrBg my Submission: 79230302

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

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

Auto comment: topic has been updated by ABIR (previous revision, new revision, compare).

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

You aren't initializing row and col in main. So ideone and codeblocks probably set everything to false for you, but CodeForces doesn't.

I suggest making row and col global, since you need to use them in another function anyway. This should zero-initialize all values in the array.

Also, you may face RE or undefined behavior from index out of bounds in your northpole function.

while(s[i][p]!='#' and p<m)p++;
while(s[i][q]!='#' and q>=0)q--;

Your bounds check comes after using p or q as an index in the string.