Изменения рейтингов за последние раунды временно удалены. Скоро они будут возвращены. ×

Блог пользователя WA_TLE_Procastinate_AC

Автор WA_TLE_Procastinate_AC, история, 4 года назад, По-английски

I am trying this problem.

Here are two of my submissions: Attempt1 Attempt2

In Attempt1 I am getting runtime error while iterating over vector p, although I am checking it's bounds, while in Attempt2 when I explicitly check if the size of vector p is zero, then there is no runtime error.

I don't think there should be an explicit need to check the size of vector p, as the loop below that won't get executed if it is empty.

Can anyone help out what is the issue?

  • Проголосовать: нравится
  • +6
  • Проголосовать: не нравится

»
4 года назад, # |
Rev. 2   Проголосовать: нравится 0 Проголосовать: не нравится

It is because p.size() is unsigned, so p.size() - 1 will become some big positive integer when the vector is empty.