Submission #258906

# Submission time Handle Problem Language Result Execution time Memory
258906 2020-08-06T17:41:07 Z Haunted_Cpp Pipes (CEOI15_pipes) C++17
10 / 100
2393 ms 65540 KB
/**
 *  author: Haunted_Cpp
**/
 
#include <bits/stdc++.h>
using namespace std;
 
#pragma GCC optimize("Ofast")
#pragma GCC target("fma,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC optimize("unroll-loops")
 
template<typename T> ostream &operator << (ostream &os, const vector<T> &v) { os << '{'; string sep; for (const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
template<typename T, size_t size> ostream &operator << (ostream &os, const array<T, size> &arr) { os << '{'; string sep; for (const auto &x : arr) os << sep << x, sep = ", "; return os << '}'; }
template<typename A, typename B> ostream &operator << (ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }
 
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << ' ' << H; debug_out(T...); }
 
#ifdef LOCAL
#define debug(...) cerr << "(" << #__VA_ARGS__ << "):", debug_out(__VA_ARGS__)
#else
#define debug(...) 47
#endif

vector<vector<int>> g;
vector<int> low, disc;
int Time = 0;

void dfs(int node, int p) {
  low[node] = disc[node] = ++Time;
  for (auto to : g[node]) {
    if (to == p) continue;
    if (!disc[to]) dfs(to, node);
    low[node] = min(low[node], low[to]);
    if (disc[node] < low[to]) {
      cout << node + 1 << ' ' << to + 1 << '\n';
    }
  }
}

int main () {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  Time = 0;
  low = disc = vector<int>(n);
  g.resize(n);
  for (int i = 0; i < m; i++) {
    int st, et;
    cin >> st >> et;
    --st; --et;
    g[st].emplace_back(et);
    g[et].emplace_back(st);
  }
  for (int i = 0; i < n; i++) if(!disc[i]) dfs(i, -1);
  return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
2 Incorrect 0 ms 384 KB Wrong number of edges
# Verdict Execution time Memory Grader output
1 Correct 4 ms 1152 KB Output is correct
2 Incorrect 4 ms 896 KB Wrong number of edges
# Verdict Execution time Memory Grader output
1 Correct 135 ms 14072 KB Output is correct
2 Correct 134 ms 13436 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 243 ms 22008 KB Memory limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 457 ms 40184 KB Memory limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 831 ms 52472 KB Memory limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1304 ms 65536 KB Memory limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1783 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2281 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2393 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -