Always_WA14's blog

By Always_WA14, history, 3 days ago, In English

Hi codeforces community, I was solving 1820B - JoJo's Incredible Adventures and I got WA when I used s.length()*s.length(), but got AC when I used n*n (but n is the same as s.length()).

Is this supposed to happen?

299256114 is the AC code and 299255008 is the other one. Check the second "else if" statement at the end.

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

»
3 days ago, # |
  Vote: I like it 0 Vote: I do not like it

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

»
3 days ago, # |
  Vote: I like it +11 Vote: I do not like it

s.length() is a value of type size_t, which only stores from 0 up to 2^32, so it'll overflow if you try to multiply (since n^2 can be up to 1e10 or so)