Submission #205798

#TimeUsernameProblemLanguageResultExecution timeMemory
205798Mamnoon_SiamPipes (CEOI15_pipes)C++17
0 / 100
101 ms14204 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; using ii = pair<int, int>; using vi = vector<int>; const int N = 1e5 + 5; int n, m; struct dsu { int par[N]; dsu() { memset(par, 0, sizeof par); iota(par, par + N, 0); } int find(int u) { return u == par[u] ? u : par[u] = find(par[u]); } int unite(int u, int v) { u = find(u), v = find(v); if(u == v) return 0; par[u] = v; return 1; } } ds1, ds2; int low[N], in[N], tym = 0; vector<int> g[N]; void dfs(int u, int dad = 0) { in[u] = low[u] = ++tym; for(int v : g[u]) if(v != dad) { if(in[v]) { low[u] = min(low[u], in[v]); } else { dfs(v, u); low[u] = min(low[u], low[v]); if(low[v] > in[u]) { printf("%d %d\n", u, v); } } } } int main(int argc, char const *argv[]) { #ifdef LOCAL freopen("in", "r", stdin); #endif scanf("%d %d", &n, &m); for(int i = 0; i < m; i++) { int u, v; scanf("%d %d", &u, &v); if(ds1.unite(u, v) or ds2.unite(u, v)) { g[u].emplace_back(v); g[v].emplace_back(u); } else { assert(false); } } for(int i = 1; i <= n; i++) { if(!in[i]) { dfs(i); } } return 0; }

Compilation message (stderr)

pipes.cpp: In function 'int main(int, const char**)':
pipes.cpp:51:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d", &n, &m);
   ~~~~~^~~~~~~~~~~~~~~~~
pipes.cpp:54:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d", &u, &v);
     ~~~~~^~~~~~~~~~~~~~~~~
#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...