Need help to indentify uncommon Out of Bound Error

Revision en1, by GlydonNeedsDedication, 2024-02-21 23:01:15

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'
    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();

Tags help, uniqueness, out of bound

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en4 English GlydonNeedsDedication 2024-02-21 23:07:24 36
en3 English GlydonNeedsDedication 2024-02-21 23:05:11 23
en2 English GlydonNeedsDedication 2024-02-21 23:02:14 29 Tiny change: 'of bounds'\n n = ' -> 'of bounds' though working fine in LOCAL\n n = '
en1 English GlydonNeedsDedication 2024-02-21 23:01:15 768 Initial revision (published)