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

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

Can anyone assist me with why this code 250814216 gives runtime error??

the code is for the E problem which was asked on the Codeforces Round 933 (Div. 3)

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

»
3 года назад, скрыть # |
 
Проголосовать: нравится +1 Проголосовать: не нравится
for (int j = 1; j < d + 1; j++) {
    dp[j] = a[i][j] + 1;

When d = m, j goes out of vector

You can put

dp[j] = a[i].at(j) + 1;

to see that

terminate called after throwing an instance of 'std::out_of_range'
  what():  vector::_M_range_check: __n (which is 5) >= this->size() (which is 5)