Please subscribe to the official Codeforces channel in Telegram via the link https://t.me/codeforces_official. ×

ABIR's blog

By ABIR, history, 4 years ago, In English

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

  • Vote: I like it
  • 0
  • Vote: I do not like it

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

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

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

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.

  • »
    »
    4 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Thank you very much dear. got AC. I will remember next.