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

#include <algorithm>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
const int MN = 110;
int V;
vector<int> G[MN];
vector<int> rG[MN];
vector<int> vs;
bool used[MN];
int cmp[MN];

void add_edge(int from, int to) {
  G[from].push_back(to);
  rG[to].push_back(from);
}

void dfs(int v) {
  used[v] = true;
  for (int i = 0; i < G[v].size(); i++) {
    if (!used[G[v][i]])
      dfs(G[v][i]);
  }
  vs.push_back(v);
}

void rdfs(int v, int k) {
  used[v] = true;
  cmp[v] = k;
  for (int i = 0; i < rG[v].size(); i++) {
    if (!used[rG[v][i]])
      rdfs(rG[v][i], k);
  }
}

int scc() {
  memset(used, 0, sizeof(used));
  vs.clear();
  for (int v = 0; v < V; v++) {
    if (!used[v])
      dfs(v);
  }
  memset(used, 0, sizeof(used));
  int k = 0;
  for (int i = vs.size() - 1; i >= 0; i--) {
    if (!used[vs[i]])
      rdfs(vs[i], k++);
  }
  return k;
}

int g[MN][MN];
bool solve() {
  for (int i = 0; i < V; i++) {
    if (g[i][i])
      return false;
  }
  for (int i = 0; i < V; i++) {
    for (int j = 0; j < V; j++) {
      if (g[i][j])
        add_edge(i, j);
    }
  }
  return scc() == V;
}

int main() {
  int n;
  int s[MN][MN][2];
  for (int i = 0; i < MN; i++) {
    for (int j = 0; j < MN; j++) {
      s[i][j][0] = 0;
      s[i][j][1] = 1000;
    }
  }
  cin >> V >> n;
  for (int i = 0; i < V; i++) {
    int k;
    cin >> k;
    for (int j = 0; j < k; j++) {
      int a, b;
      char c;
      scanf("%d %c= %d", &a, &c, &b);
      a--;
      if (c == '>') {
        s[i][a][0] = max(s[i][a][0], b);
      } else {
        s[i][a][1] = min(s[i][a][1], b);
      }
    }
  }
  for (int i = 0; i < V; i++) {
    for (int j = 0; j < V; j++) {
      bool f = false;
      for (int k = 0; k < MN; k++) {
        if (s[i][k][0] > s[j][k][1]) {
          f = true;
        }
      }
      g[i][j] = f ? 1 : 0;
    }
  }
  if (solve()) {
    printf("Yes\\n");
  } else {
    printf("No\\n");
  }
  return 0;
}

Error: -11

Fixed submission:

#include <algorithm>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
const int MN = 1100;
int V;
vector<int> G[MN];
vector<int> rG[MN];
vector<int> vs;
bool used[MN];
int cmp[MN];

void add_edge(int from, int to) {
  G[from].push_back(to);
  rG[to].push_back(from);
}

void dfs(int v) {
  used[v] = true;
  for (int i = 0; i < G[v].size(); i++) {
    if (!used[G[v][i]])
      dfs(G[v][i]);
  }
  vs.push_back(v);
}

void rdfs(int v, int k) {
  used[v] = true;
  cmp[v] = k;
  for (int i = 0; i < rG[v].size(); i++) {
    if (!used[rG[v][i]])
      rdfs(rG[v][i], k);
  }
}

int scc() {
  memset(used, 0, sizeof(used));
  vs.clear();
  for (int v = 0; v < V; v++) {
    if (!used[v])
      dfs(v);
  }
  memset(used, 0, sizeof(used));
  int k = 0;
  for (int i = vs.size() - 1; i >= 0; i--) {
    if (!used[vs[i]])
      rdfs(vs[i], k++);
  }
  return k;
}
int m;
int g[MN][MN];
bool solve() {
  for (int i = 0; i < m; i++) {
    if (g[i][i])
      return false;
  }
  V = m;
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < m; j++) {
      if (g[i][j])
        add_edge(i, j);
    }
  }
  return scc() == m;
}

int main() {
  int n;
  int s[MN][MN][2];
  for (int i = 0; i < MN; i++) {
    for (int j = 0; j < MN; j++) {
      s[i][j][0] = 0;
      s[i][j][1] = 1000;
    }
  }
  cin >> m >> n;
  for (int i = 0; i < m; i++) {
    int k;
    cin >> k;
    for (int j = 0; j < k; j++) {
      int a, b;
      char c;
      scanf("%d %c= %d", &a, &c, &b);
      a--;
      s[i][a][(c == '<') ? 1 : 0] = b;
    }
  }
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < m; j++) {
      bool f = false;
      for (int k = 0; k < MN; k++) {
        if (s[i][k][0] > s[j][k][1]) {
          f = true;
        }
      }
      g[i][j] = f ? 1 : 0;
    }
  }
  if (solve()) {
    printf("Yes\\n");
  } else {
    printf("No\\n");
  }
  return 0;
}