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

/*
 *
 *
 */

#include <bits/stdc++.h>

using namespace std;

#define LOG(...) fprintf(stderr, __VA_ARGS__)
// #define LOG(...)
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define RREP(i, n) for (int i = (int)(n - 1); i >= 0; --i)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SQ(n) (n) * (n)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<pii> vpi;
typedef vector<pll> vpl;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vc> vvc;
typedef vector<vll> vvll;

struct Team {
  int correct;
  int penalty;
  int vpenalty[10];
  int id;

  bool operator<(const Team &p) const {
    if (correct == p.correct)
      if (penalty == p.penalty)
        return id < p.id;
      else
        return penalty > p.penalty;
    else
      return correct < p.correct;
  }

  bool operator==(const Team &p) const {
    if (correct == p.correct)
      return penalty == p.penalty;
    else
      return correct == p.correct;
  }
};

int main() {
  int M, T, P, R;
  while (cin >> M >> T >> P >> R, M | T | P | R) {
    vector<Team> team(T);
    REP(i, T) { team[i].id = i + 1; }

    REP(i, R) {
      int m, t, p, j;
      cin >> m >> t >> p >> j;
      t--;
      p--;

      if (j) {
        team[t].vpenalty[p] += 20;
      } else {
        team[t].correct++;
        team[t].penalty += m + team[t].vpenalty[p];
      }
    }
    RSORT(team);
    cout << team[0].id;
    FOR(i, 1, T) {
      if (team[i - 1] == team[i])
        cout << '=';
      else
        cout << ',';
      cout << team[i].id;
    }
    cout << endl;
  }
}

Error: -11

Fixed submission:

/*
 *
 *
 */

#include <bits/stdc++.h>

using namespace std;

#define LOG(...) fprintf(stderr, __VA_ARGS__)
// #define LOG(...)
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define RREP(i, n) for (int i = (int)(n - 1); i >= 0; --i)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SQ(n) (n) * (n)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<pii> vpi;
typedef vector<pll> vpl;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vc> vvc;
typedef vector<vll> vvll;

struct Team {
  int correct;
  int penalty;
  int vpenalty[10];
  int id;

  bool operator<(const Team &p) const {
    if (correct == p.correct)
      if (penalty == p.penalty)
        return id < p.id;
      else
        return penalty > p.penalty;
    else
      return correct < p.correct;
  }

  bool operator==(const Team &p) const {
    if (correct == p.correct)
      return penalty == p.penalty;
    else
      return correct == p.correct;
  }
};

int main() {
  int M, T, P, R;
  while (cin >> M >> T >> P >> R) {
    vector<Team> team(T);
    REP(i, T) { team[i].id = i + 1; }

    REP(i, R) {
      int m, t, p, j;
      cin >> m >> t >> p >> j;
      t--;
      p--;

      if (j) {
        team[t].vpenalty[p] += 20;
      } else {
        team[t].correct++;
        team[t].penalty += m + team[t].vpenalty[p];
      }
    }
    RSORT(team);
    cout << team[0].id;
    FOR(i, 1, T) {
      if (team[i - 1] == team[i])
        cout << '=';
      else
        cout << ',';
      cout << team[i].id;
    }
    cout << endl;
  }
}