Submission #585581

#TimeUsernameProblemLanguageResultExecution timeMemory
5855811zaid1Pipes (CEOI15_pipes)C++17
0 / 100
1814 ms65536 KiB
#include <bits/stdc++.h> using namespace std; #define endl '\n' const int M = 1e5+1; vector<int> node[M]; int a[M], d[M], tt = 1; bitset<100005> vis; vector<pair<int, int>> ans; void dfs(int s) { a[s] = tt++; vis[s] = true; for (int i:node[s]) if (!vis[i]) dfs(i); d[s] = tt++; } void dfs2(int s, int p = 1) { vis[s] = true; for (int i:node[s]) { if (!vis[i]) dfs2(i, s); if (i != p) a[s] = min(a[s], a[i]); if (i != p) d[s] = max(d[s], d[i]); } } void dfs3(int s) { vis[s] = true; for (int i:node[s]) { if (!vis[i]) { if (d[i] < d[s] && a[i] > a[s]) ans.push_back({s, i}); dfs3(i); } } } signed main() { cin.tie(0)->sync_with_stdio(0); int n, m; cin >> n >> m; for (int i = 1; i <= m; i++) { int a, b; cin >> a >> b; node[a].push_back(b); node[b].push_back(a); } for (int i = 1; i <= n; i++) if (!vis[i]) dfs(i); vis = 0; for (int i = 1; i <= n; i++) if (!vis[i]) dfs2(i); vis = 0; for (int i = 1; i <= n; i++) if (!vis[i]) dfs3(i); vis = 0; for (auto [a, b]:ans) cout << a << ' ' << b << endl; return 0; } /* 10 11 1 7 1 8 1 6 2 8 6 7 5 8 2 5 2 3 2 4 3 4 10 9 */

Compilation message (stderr)

pipes.cpp: In function 'int main()':
pipes.cpp:50:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   50 |     for (int i = 1; i <= n; i++) if (!vis[i]) dfs(i); vis = 0;
      |     ^~~
pipes.cpp:50:55: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   50 |     for (int i = 1; i <= n; i++) if (!vis[i]) dfs(i); vis = 0;
      |                                                       ^~~
pipes.cpp:51:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   51 |     for (int i = 1; i <= n; i++) if (!vis[i]) dfs2(i); vis = 0;
      |     ^~~
pipes.cpp:51:56: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   51 |     for (int i = 1; i <= n; i++) if (!vis[i]) dfs2(i); vis = 0;
      |                                                        ^~~
pipes.cpp:52:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   52 |     for (int i = 1; i <= n; i++) if (!vis[i]) dfs3(i); vis = 0;
      |     ^~~
pipes.cpp:52:56: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   52 |     for (int i = 1; i <= n; i++) if (!vis[i]) dfs3(i); vis = 0;
      |                                                        ^~~
#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...