rachitag246's blog

By rachitag246, history, 3 years ago, In English

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)

  • Vote: I like it
  • -1
  • Vote: I do not like it

| Write comment?
»
3 years ago, hide # |
 
Vote: I like it +1 Vote: I do not like it
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)