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

//------------------------------------------
// C++ templete
//------------------------------------------
#include <bits/stdc++.h>
// #define int long long
using namespace std;

// typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<VS> VVS;

// REPEAT
//------------------------------------------
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

// container util
//------------------------------------------
#define pb push_back
#define ALL(a) (a).begin(), (a).end()
#define PRINT(V)                                                               \\
  for (auto v : (V))                                                           \\
  cout << v << " "
#define PRINTL(V)                                                              \\
  for (auto v : (V))                                                           \\
  cout << v << endl
#define SORT(V) sort((V).begin(), (V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())

// 最大公約数
//------------------------------------------
int GCD(int a, int b) { return b ? GCD(b, a % b) : a; }

// grobal variable
//------------------------------------------
int N, M;
VI Vec;

// main
//------------------------------------------
signed main() {
  int n, m;
  cin >> n >> m;
  VI h(n);
  VI a(m);
  VI b(m);
  VI t(n, 0);
  for (int i = 0; i < n; i++) {
    cin >> h[i];
  }
  for (int i = 0; i < m; i++) {
    cin >> a[i] >> b[i];
  }
  for (int i = 0; i < m; i++) {
    if (h[a[i] - 1] > h[b[i] - 1]) {
      t[b[i] - 1] = 1;
    } else if (h[a[i] - 1] == h[b[i] - 1]) {
      t[b[i] - 1] = 1;
      t[a[i] - 1] = 1;
    } else {
      t[a[i] - 1] = 1;
    }
  }
  int c = 0;
  for (auto &e : t) {
    if (e == 0) {
      c++;
    }
  }
  cout << c;
}

Error: WA

Fixed submission:

//------------------------------------------
// C++ templete
//------------------------------------------
#include <bits/stdc++.h>
// #define int long long
using namespace std;

// typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<VS> VVS;

// REPEAT
//------------------------------------------
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

// container util
//------------------------------------------
#define pb push_back
#define ALL(a) (a).begin(), (a).end()
#define PRINT(V)                                                               \\
  for (auto v : (V))                                                           \\
  cout << v << " "
#define PRINTL(V)                                                              \\
  for (auto v : (V))                                                           \\
  cout << v << endl
#define SORT(V) sort((V).begin(), (V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())

// 最大公約数
//------------------------------------------
int GCD(int a, int b) { return b ? GCD(b, a % b) : a; }

// grobal variable
//------------------------------------------
int N, M;
VI Vec;

// main
//------------------------------------------
signed main() {
  int n, m;
  cin >> n >> m;
  VI h(n);
  VI a(n);
  VI b(n);
  VI t(n, 0);
  for (int i = 0; i < m; i++) {
    cin >> h[i];
  }
  for (int i = 0; i < m; i++) {
    cin >> a[i] >> b[i];
  }
  for (int i = 0; i < m; i++) {
    if (h[a[i]] > h[b[i]]) {
      t[b[i]] = 1;
    } else {
      t[a[i]] = 1;
    }
  }
  int c = 0;
  for (auto &e : t) {
    if (e == 0) {
      c++;
    }
  }
  cout << c;
}