Need help to indentify uncommon Out of Bound Error

Правка en2, от GlydonNeedsDedication, 2024-02-21 23:02:14

for the Problem 1849C

The SOLUTION I wrote, it is having some out of bounds error in the below code portion.

    s += (char)('0' ^ '1' ^ s.back());
    s = ("" + (char)('0' ^ '1' ^ s[0])) + s; // this line giving error 'out of bounds' though working fine in LOCAL
    n = s.size();

I am not able detect the exact reason.

Same purpose If I try to do like below, its not throwing any error

// working as expected
    if (s.size() > 0) s += (char)('0' ^ '1' ^ s.back());
    reverse(all(s));
    if (s.size() > 0) s += (char)('0' ^ '1' ^ s.back());
    reverse(all(s));
    n = s.size();

Теги help, uniqueness, out of bound

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en4 Английский GlydonNeedsDedication 2024-02-21 23:07:24 36
en3 Английский GlydonNeedsDedication 2024-02-21 23:05:11 23
en2 Английский GlydonNeedsDedication 2024-02-21 23:02:14 29 Tiny change: 'of bounds'\n n = ' -> 'of bounds' though working fine in LOCAL\n n = '
en1 Английский GlydonNeedsDedication 2024-02-21 23:01:15 768 Initial revision (published)