Submission #563680

#TimeUsernameProblemLanguageResultExecution timeMemory
563680mjhmjh1104Pipes (CEOI15_pipes)C++17
10 / 100
2059 ms65536 KiB
#include <cstdio> #include <vector> #include <algorithm> using namespace std; const int MAX = 100003; int v, e, cntDfs, dfsN[MAX]; vector<int> adj[MAX]; vector<pair<int, int>> r; int dfs(int x, int prev = -1) { int res = dfsN[x] = cntDfs++; for (auto &i: adj[x]) { if (i == prev) continue; if (dfsN[i]) res = min(res, dfsN[i]); else if (!dfsN[i]) { int t = dfs(i, x); res = min(res, t); if (t <= dfsN[x]) continue; r.push_back({ x, i }); } } return res; } int main() { scanf("%d%d", &v, &e); for (int i = 0; i < e; i++) { int a, b; scanf("%d%d", &a, &b); a--, b--; adj[a].push_back(b); adj[b].push_back(a); } for (int i = 0; i < v; i++) if (!dfsN[i]) dfs(i); for (auto &i: r) i = make_pair(min(i.first, i.second), max(i.first, i.second)); sort(r.begin(), r.end()); for (auto &i: r) printf("%d %d\n", i.first + 1, i.second + 1); }

Compilation message (stderr)

pipes.cpp: In function 'int main()':
pipes.cpp:28:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   28 |     scanf("%d%d", &v, &e);
      |     ~~~~~^~~~~~~~~~~~~~~~
pipes.cpp:31:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   31 |         scanf("%d%d", &a, &b);
      |         ~~~~~^~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...