Submission #948352

# Submission time Handle Problem Language Result Execution time Memory
948352 2024-03-18T04:41:10 Z vjudge1 Pipes (CEOI15_pipes) C++17
20 / 100
3 ms 1884 KB
#include <bits/stdc++.h>
using namespace std;
#define int short
#define all(x) x.begin(), x.end()
#define size(x) (int)x.size()

template<class S, class T>
bool chmin(S &a, const T &b) {
  return a > b ? (a = b) == b : false;
}
template<class S, class T>
bool chmax(S &a, const T &b) {
  return a < b ? (a = b) == b : false;
}

vector<vector<pair<int, int>>> g;
vector<bool> vis;
vector<int> tin, fup;
int timer;
set<pair<int, int>> st;
 
void dfs(int v, int p = -1, int idx = -1) {
  vis[v] = true;
  tin[v] = fup[v] = ++timer;
  for (auto [to, new_idx] : g[v]) {
    if (idx == new_idx) continue;
    else if (vis[to]) chmin(fup[v], tin[to]);
    else {
      dfs(to, v, new_idx);
      chmin(fup[v], fup[to]);
      if (fup[to] > tin[v]) {
        st.insert({min(v, to), max(to, v)});
      }
    }
  }
}

signed main() {
  cin.tie(nullptr)->sync_with_stdio(false);
  int n, m; cin >> n >> m;
  g.resize(n);
  vis.assign(n, false);
  tin.resize(n), fup.resize(n);
  vector<pair<int, int>> v;
  for (int i = 0; i < m; ++i) {
    int a, b; cin >> a >> b;
    a--, b--;
    g[a].push_back({b, i});
    g[b].push_back({a, i});
    v.push_back({min(a, b), max(a, b)});
  }
  for (int i = 0; i < n; ++i) {
    if (!vis[i]) dfs(i);
  }
  for (auto [a, b] : v) {
    if (st.count({a, b})) {
      cout << a + 1 << ' ' << b + 1 << '\n';
    }
  }
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1116 KB Output is correct
2 Correct 3 ms 860 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 600 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 1116 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 1884 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1116 KB Output is correct
2 Incorrect 1 ms 1372 KB Wrong number of edges
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1112 KB Output is correct
2 Incorrect 1 ms 1368 KB Wrong number of edges
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1116 KB Output is correct
2 Incorrect 1 ms 1372 KB Wrong number of edges
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1112 KB Output is correct
2 Incorrect 1 ms 1240 KB Wrong number of edges
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1284 KB Output is correct
2 Incorrect 1 ms 1232 KB Wrong number of edges
3 Halted 0 ms 0 KB -