Problem p00706 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#include <queue>
#include <vector>

using namespace std;

int persimmon_cnt(vector<vector<int>> vv, int s, int t, int y, int x) {
  int cnt = 0;
  for (int i = 0; i < t; i++) {
    for (int j = 0; j < s; j++) {
      // cout << "y = " << y+i << " x = " << x+j << endl;
      if (vv[y + i][x + j] == 1) {
        // cout << "x = " << x+j << " y = " << y+i << endl;
        cnt++;
      }
    }
  }
  // cout << endl;
  return cnt;
}
int search_max(vector<vector<int>> vv, int s, int t) {
  int max = 0;
  for (int i = 0; i <= vv.size() - t; i++) {           // 83
    for (int j = 0; j <= vv.front().size() - s; j++) { // 93
      // cout << "i = " << i << " j = " << j << endl;
      int persimmon = persimmon_cnt(vv, s, t, i, j);
      // cout << vv[i][j] ;
      if (max < persimmon)
        max = persimmon;
    }
    // cout << endl;
  }
  return max;
}
void print(vector<vector<int>> vv) {
  for (int i = 0; i < vv.size(); i++) {
    for (int j = 0; j < vv.front().size(); j++) {
      cout << vv[i][j];
    }
    // cout << endl;
  }
}
int main() {
  while (1) {
    int n;
    cin >> n;
    if (n == 0)
      break;
    int w, h;
    cin >> w >> h;
    vector<vector<int>> field(h, vector<int>(w, 0));
    // cout << field.size() <<" "<<  field.front().size() << endl;
    //             8                       10
    // cout << field[7][9] << endl;
    for (int i = 0; i < n; i++) {
      int x, y;
      cin >> x >> y;
      // cout <<"i = " << i << " " <<  x << " " << y << endl;
      field[y - 1][x - 1] = 1;
    }
    // print(field);
    int s, t;
    cin >> s >> t;
    // cout << field.front().size() - s << endl;
    // cout << field.size() - t << endl;

    cout << search_max(field, s, t) << endl;
    ;
  }
  return 0;
}

Error: 0

Fixed submission:

#include <iostream>
#include <queue>
#include <vector>

using namespace std;

int persimmon_cnt(vector<vector<int>> vv, int s, int t, int x, int y) {
  int cnt = 0;
  for (int i = 0; i < t; i++) {
    for (int j = 0; j < s; j++) {
      // cout << "x = " << x+j << " y = " << y+i << endl;
      if (vv[y + i][x + j] == 1) {
        // cout << "x = " << x+j << " y = " << y+i << endl;
        cnt++;
      }
    }
  }
  // cout << endl;
  return cnt;
}
int search_max(vector<vector<int>> vv, int s, int t) {
  int max = 0;
  for (int i = 0; i <= vv.front().size() - t - 1; i++) {
    for (int j = 0; j <= vv.front().size() - s - 1; j++) {
      // cout << "i = " << i << " j = " << j << endl;
      int persimmon = persimmon_cnt(vv, s, t, i, j);
      // cout << vv[i][j] ;
      if (max < persimmon)
        max = persimmon;
    }
    // cout << endl;
  }
  return max;
}
void print(vector<vector<int>> vv) {
  for (int i = 0; i < vv.size(); i++) {
    for (int j = 0; j < vv.front().size(); j++) {
      cout << vv[i][j];
    }
    // cout << endl;
  }
}
int main() {
  while (1) {
    int n;
    cin >> n;
    if (n == 0)
      break;
    int w, h;
    cin >> w >> h;
    vector<vector<int>> field(h, vector<int>(w, 0));
    // cout << field.size() <<" "<<  field.front().size() << endl;
    //             8                       10
    // cout << field[7][9] << endl;
    for (int i = 0; i < n; i++) {
      int x, y;
      cin >> x >> y;
      // cout << x << " " << y << endl;
      field[y - 1][x - 1] = 1;
    }
    // print(field);
    int s, t;
    cin >> s >> t;
    cout << search_max(field, s, t) << endl;
    ;
  }
  return 0;
}