Problem p00550 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <iostream>
#include <queue>
#include <unordered_set>
#define DEBUG

using std::endl;
constexpr int32_t INF = 1000000000;

std::unordered_set<int32_t> graph[100000];
int32_t path[100000][2];
int32_t N, M, Q;
int32_t D[100000];
void dij(int32_t s) {
  using P = std::pair<int32_t, int32_t>;
  std::queue<P> que;
  for (auto &i : D)
    i = INF;
  D[0] = 0;
  que.emplace(0, 0);
  while (!que.empty()) {
    auto n = que.front();
    que.pop();
    if (D[n.second] < n.first) {
      continue;
    }

    for (auto &e : graph[n.second]) {
      auto cost = n.first + 1;
      if (cost < D[e]) {
        D[e] = cost;
        que.emplace(cost, e);
      }
    }
  }
}

int main() {
  std::cin >> N >> M >> Q;
  for (int i = 0; i < M; ++i) {
    std::cin >> path[i][0] >> path[i][1];
    --path[i][0];
    --path[i][1];
    graph[path[i][0]].insert(path[i][1]);
    graph[path[i][1]].insert(path[i][0]);
  }

  dij(0);

  int32_t count = 0;
  for (int i = 0; i < Q; ++i) {
    int32_t R;
    std::cin >> R;
    --R;

    int32_t from = path[R][0];
    int32_t to = path[R][1];
    graph[from].erase(graph[from].find(to));
    graph[to].erase(graph[to].find(from));

    if (D[to] == D[from]) {
      std::cout << count << endl;
      continue;
    }
    if (D[to] < D[from]) {
      std::swap(from, to);
    }
    if (D[to] >= INF) {
      std::cout << count << endl;
      continue;
    }

    // 辺を逆にたどる
    bool used[100000] = {}; //[1]:tmp
    std::queue<int32_t> que;
    que.emplace(to);
    used[to] = true;
    while (!que.empty()) {
      auto n = que.front();
      que.pop();
      if (D[n] >= INF) {
        continue;
      }

      bool path_is_exsists = false;
      for (auto &e : graph[n]) {
        if (D[e] < D[n]) {
          path_is_exsists = true;
          break;
        }
      }
      if (path_is_exsists) {
        // OK
      } else {
        ++count;
        D[n] = INF;
        for (auto &e : graph[n]) {
          if (!used[e] && D[e] < INF) {
            used[e] = true;
            que.push(e);
          }
        }
      }
    }

    std::cout << count << endl;
  }
}

Fixed submission:
#include <algorithm>
#include <iostream>
#include <queue>
#include <unordered_set>
#define DEBUG

using std::endl;
constexpr int32_t INF = 1000000000;

std::unordered_set<int32_t> graph[100000];
int32_t path[200000][2];
int32_t N, M, Q;
int32_t D[100000];
void dij(int32_t s) {
  using P = std::pair<int32_t, int32_t>;
  std::queue<P> que;
  for (auto &i : D)
    i = INF;
  D[0] = 0;
  que.emplace(0, 0);
  while (!que.empty()) {
    auto n = que.front();
    que.pop();
    if (D[n.second] < n.first) {
      continue;
    }

    for (auto &e : graph[n.second]) {
      auto cost = n.first + 1;
      if (cost < D[e]) {
        D[e] = cost;
        que.emplace(cost, e);
      }
    }
  }
}

int main() {
  std::cin >> N >> M >> Q;
  for (int i = 0; i < M; ++i) {
    std::cin >> path[i][0] >> path[i][1];
    --path[i][0];
    --path[i][1];
    graph[path[i][0]].insert(path[i][1]);
    graph[path[i][1]].insert(path[i][0]);
  }

  dij(0);

  int32_t count = 0;
  for (int i = 0; i < Q; ++i) {
    int32_t R;
    std::cin >> R;
    --R;

    int32_t from = path[R][0];
    int32_t to = path[R][1];
    graph[from].erase(graph[from].find(to));
    graph[to].erase(graph[to].find(from));

    if (D[to] == D[from]) {
      std::cout << count << endl;
      continue;
    }
    if (D[to] < D[from]) {
      std::swap(from, to);
    }
    if (D[to] >= INF) {
      std::cout << count << endl;
      continue;
    }

    // 辺を逆にたどる
    bool used[100000] = {}; //[1]:tmp
    std::queue<int32_t> que;
    que.emplace(to);
    used[to] = true;
    while (!que.empty()) {
      auto n = que.front();
      que.pop();
      if (D[n] >= INF) {
        continue;
      }

      bool path_is_exsists = false;
      for (auto &e : graph[n]) {
        if (D[e] < D[n]) {
          path_is_exsists = true;
          break;
        }
      }
      if (path_is_exsists) {
        // OK
      } else {
        ++count;
        D[n] = INF;
        for (auto &e : graph[n]) {
          if (!used[e] && D[e] < INF) {
            used[e] = true;
            que.push(e);
          }
        }
      }
    }

    std::cout << count << endl;
  }
}