Problem p03575 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
#include <vector>
#define rep(i, s, n) for (int i = s; i < n; i++)
#define repe(i, s, n) for (int i = s; i <= n; i++)
using namespace std;
static const int MAX_V = 100000;

// Graph Element
struct E {
  E(int t, int f) {
    to = t;
    from = f;
  }
  E(int t, int f, int c) {
    to = t;
    from = f;
    cost = c;
  }
  int to;
  int from;
  int cost;
  bool visited;
  bool use;
};
struct V {
  vector<E *> edge;
  bool visited;
};
V G[MAX_V];
/////////////////////////////////////////////

// dfs
int ans = 0;
int VS, ES;
void dfs(int n) {
  rep(i, 0, G[n].edge.size()) {
    if (G[n].edge[i]->use && !G[G[n].edge[i]->to].visited) {
      G[G[n].edge[i]->to].visited = true;
      dfs(G[n].edge[i]->to);
    }
  }
}

//
void bfs(int n) {
  int q[50] = {};
  int s = 0, e = 0;
  q[e++] = n;
  int c = 0;

  while (s < e) {
    c = q[s++];
    G[c].visited = true;

    rep(i, 0, G[c].edge.size()) {
      if (G[c].edge[i]->use && !G[G[c].edge[i]->to].visited) {
        q[e++] = G[c].edge[i]->to;
      }
    }
  }
}

int main() {
  cin >> VS >> ES;

  rep(i, 0, ES) {
    int s, t;
    cin >> s >> t;
    G[s].edge.push_back(new E(t, s));
    G[t].edge.push_back(new E(s, t));
  }

  ///////////////////////////////////////////////////////////
  // DFS
  // Edge all false
  repe(i, 1, VS) rep(j, 0, G[i].edge.size()) {
    // Edge all visited false;
    repe(k, 1, VS) rep(l, 0, G[k].edge.size()) G[k].edge[l]->use = true;
    repe(k, 1, VS) G[k].visited = false;

    G[i].edge[j]->use = false;

    // DFS
    G[1].visited = true;
    // dfs(1);
    bfs(1);

    bool ok = true;
    repe(k, 1, VS) ok &= G[k].visited;
    if (!ok)
      ans++;
  }

  cout << ans << endl;

  return 0;
}

Fixed submission:
#include <iostream>
#include <vector>
#define rep(i, s, n) for (int i = s; i < n; i++)
#define repe(i, s, n) for (int i = s; i <= n; i++)
using namespace std;
static const int MAX_V = 100000;

// Graph Element
struct E {
  E(int t, int f) {
    to = t;
    from = f;
  }
  E(int t, int f, int c) {
    to = t;
    from = f;
    cost = c;
  }
  int to;
  int from;
  int cost;
  bool visited;
  bool use;
};
struct V {
  vector<E *> edge;
  bool visited;
};
V G[MAX_V];
/////////////////////////////////////////////

// dfs
int ans = 0;
int VS, ES;
void dfs(int n) {
  rep(i, 0, G[n].edge.size()) {
    if (G[n].edge[i]->use && !G[G[n].edge[i]->to].visited) {
      G[G[n].edge[i]->to].visited = true;
      dfs(G[n].edge[i]->to);
    }
  }
}

//
void bfs(int n) {
  int q[1000] = {};
  int s = 0, e = 0;
  q[e++] = n;
  int c = 0;

  while (s < e) {
    c = q[s++];
    G[c].visited = true;

    rep(i, 0, G[c].edge.size()) {
      if (G[c].edge[i]->use && !G[G[c].edge[i]->to].visited) {
        q[e++] = G[c].edge[i]->to;
      }
    }
  }
}

int main() {
  cin >> VS >> ES;

  rep(i, 0, ES) {
    int s, t;
    cin >> s >> t;
    G[s].edge.push_back(new E(t, s));
    G[t].edge.push_back(new E(s, t));
  }

  ///////////////////////////////////////////////////////////
  // DFS
  // Edge all false
  repe(i, 1, VS) rep(j, 0, G[i].edge.size()) {
    // Edge all visited false;
    repe(k, 1, VS) rep(l, 0, G[k].edge.size()) G[k].edge[l]->use = true;
    repe(k, 1, VS) G[k].visited = false;

    G[i].edge[j]->use = false;

    // DFS
    G[1].visited = true;
    // dfs(1);
    bfs(1);

    bool ok = true;
    repe(k, 1, VS) ok &= G[k].visited;
    if (!ok)
      ans++;
  }

  cout << ans << endl;

  return 0;
}