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

#include <bits/stdc++.h>

#define REP(i, s, n) for (int i = s; i < n; i++)
#define rep(i, n) REP(i, 0, n)

using namespace std;

typedef pair<string, string> string2;
vector<string2> classInfo;
vector<string2> teacher[110], student[110];
int numTeacher, numStudent;

string2 split(string s) {
  string2 ret;
  s[5] = ' ';
  stringstream ss;
  ss << s;
  ss >> ret.first >> ret.second;
  return ret;
}

int main() {
  string s;
  int n;
  cin >> n;
  rep(i, n) {
    cin >> s;
    classInfo.push_back(split(s));
  }
  cin >> numTeacher;
  rep(i, numTeacher) {
    cin >> n;
    rep(j, n) {
      cin >> s;
      teacher[i].push_back(split(s));
    }
  }

  cin >> numStudent;
  rep(i, numStudent) {
    cin >> n;
    rep(j, n) {
      cin >> s;
      student[i].push_back(split(s));
    }
  }

  int maxi = 0;
  rep(i, classInfo.size()) {
    int enableTeacher = 0, enableStudent = 0;
    rep(j, numTeacher) {
      bool enable = false;
      rep(k,
          teacher[j].size()) if (teacher[j][k].first <= classInfo[i].first &&
                                 classInfo[i].second <= teacher[j][k].second) {
        enable = true;
        break;
      }
      if (enable) {
        ++enableTeacher;
      }
    }
    rep(j, numStudent) {
      bool enable = false;
      rep(k,
          student[j].size()) if (student[j][k].first <= classInfo[i].first &&
                                 classInfo[i].second <= student[j][k].second) {
        enable = true;
        break;
      }
      if (enable) {
        ++enableStudent;
      }
    }
    maxi += min(enableTeacher, enableStudent);
  }
  cout << maxi << endl;

  return 0;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>

#define REP(i, s, n) for (int i = s; i < n; i++)
#define rep(i, n) REP(i, 0, n)

using namespace std;

typedef pair<string, string> string2;
vector<string2> classInfo;
vector<string2> teacher[110], student[110];
int numTeacher, numStudent;

string2 split(string s) {
  string2 ret;
  s[5] = ' ';
  stringstream ss;
  ss << s;
  ss >> ret.first >> ret.second;
  return ret;
}

int main() {
  string s;
  int n;
  cin >> n;
  rep(i, n) {
    cin >> s;
    classInfo.push_back(split(s));
  }
  cin >> numTeacher;
  rep(i, numTeacher) {
    cin >> n;
    rep(j, n) {
      cin >> s;
      teacher[i].push_back(split(s));
    }
  }

  cin >> numStudent;
  rep(i, numStudent) {
    cin >> n;
    rep(j, n) {
      cin >> s;
      student[i].push_back(split(s));
    }
  }

  int maxi = 0;
  rep(i, classInfo.size()) {
    int enableTeacher = 0, enableStudent = 0;
    rep(i, numTeacher) {
      bool enable = false;
      rep(j,
          teacher[i].size()) if (teacher[i][j].first <= classInfo[i].first &&
                                 classInfo[i].second <= teacher[i][j].second) {
        enable = true;
        break;
      }
      if (enable) {
        ++enableTeacher;
        break;
      }
    }
    rep(i, numStudent) {
      bool enable = false;
      rep(j,
          student[i].size()) if (student[i][j].first <= classInfo[i].first &&
                                 classInfo[i].second <= student[i][j].second) {
        enable = true;
        break;
      }
      if (enable) {
        ++enableStudent;
        break;
      }
    }
    maxi += min(enableTeacher, enableStudent);
  }
  cout << maxi << endl;

  return 0;
}