rahulb's blog

By rahulb, history, 6 years ago, In English

https://codeforces.com/contest/762/submission/41625289 This is the link to my solution to problem 762C. I am getting a runtime error on test 25 saying heap-buffer overflow. From what I got through googling I think it occurs when we try to use too much memory, but I am pretty sure I am not doing that here as I have just made 2 strings with maximum length 10^5.

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

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

Maybe it is beacuase you use b.lenght()-1. Try replacing by (int)b.lenght() — 1.

This may cause error because b.length() is an unsigned value and when b.lenght() is zero, if you decrease by 1 it overflows.