What's the reason behind the Runtime Error?
I got a runtime error on the last Atcoder Regular Contest.
The problem is this .
My RE solution here .
I used (char) (k+'0') to convert the digit k to character.
for (int k = 1; k < 7; k++) { if (!f[k]) { ch[i][j] = (char)(k + '0'); break; } }
3 3 ... ... ...
I always wrote (char) ('a'+k)to get the kth letter from the alphabet and didn't get Runtime Error on any platform.
(char) ('a'+k)
Why am I getting RE this time?
RTE here:
if (xx >= 0 && xx < n && yy >= 0 && yy < m) { int d = ch[xx][yy] - '0'; f[d] = 1; }
when ch[xx][yy] = '.', d = -2. On my machine it somehow modify the value of m and cause RTE:|
ch[xx][yy] = '.'
d = -2
m
Ah! Thank you very much.
Didn't notice that.
RTE here:
when
ch[xx][yy] = '.'
,d = -2
. On my machine it somehow modify the value ofm
and cause RTE:|Ah! Thank you very much.
Didn't notice that.