From a635aa97458191f1a1e41a01ec3adfbdbdc9c0e6 Mon Sep 17 00:00:00 2001 From: Bruno Freitas Tissei <bft15@inf.ufpr.br> Date: Mon, 11 Mar 2019 16:38:16 -0300 Subject: [PATCH] Add Cadernaveis/MANUT.cpp Signed-off-by: Bruno Freitas Tissei <bft15@inf.ufpr.br> --- contests/Cadernaveis/MANUT.cpp | 97 +++++++++++++++++++++++++++++++++ contests/ICPC_SA17/a.out | Bin 17200 -> 0 bytes 2 files changed, 97 insertions(+) create mode 100644 contests/Cadernaveis/MANUT.cpp delete mode 100755 contests/ICPC_SA17/a.out diff --git a/contests/Cadernaveis/MANUT.cpp b/contests/Cadernaveis/MANUT.cpp new file mode 100644 index 0000000..286be05 --- /dev/null +++ b/contests/Cadernaveis/MANUT.cpp @@ -0,0 +1,97 @@ +#include <bits/stdc++.h> + +#define MAX 500 +#define EPS 1e-6 +#define MOD 1000000007 +#define inf 0x3f3f3f3f +#define llinf 0x3f3f3f3f3f3f3f3f + +#define fi first +#define se second +#define pb push_back +#define ende '\n' + +#define all(x) (x).begin(), (x).end() +#define rall(x) (x).rbegin(), (x).rend() +#define mset(x, y) memset(&x, (y), sizeof(x)) + +using namespace std; + +typedef long long ll; +typedef pair<int,int> ii; + +vector<int> graph[MAX]; +int visited[MAX], parent[MAX]; + +int L[MAX]; +int low[MAX]; +vector<int> articulations; + +void dfs(int x) { + int child = 0; + visited[x] = 1; + + for (auto i : graph[x]) { + if (!visited[i]) { + child++; + parent[i] = x; + + low[i] = L[i] = L[x] + 1; + dfs(i); + + low[x] = min(low[x], low[i]); + + if ((parent[x] == -1 && child > 1) || + (parent[x] != -1 && low[i] >= L[x])) + articulations.pb(x); + + + } else if (parent[x] != i) + low[x] = min(low[x], L[i]); + } +} + +void tarjan(int n) { + mset(visited, 0); + mset(parent, -1); + mset(L, 0); + articulations.clear(); + dfs(n); + + sort(all(articulations)); + articulations.erase(unique(all(articulations)), articulations.end()); +} + +int main() { + ios::sync_with_stdio(0); + cin.tie(0); + + int n, m; + int cas = 1; + while (cin >> n >> m && (n || m)) { + for (int i = 0; i < n; ++i) + graph[i].clear(); + + for (int i = 0; i < m; ++i) { + int x, y; cin >> x >> y; + x--, y--; + graph[x].pb(y); + graph[y].pb(x); + } + + tarjan(0); + cout << "Teste " << cas << ende; + if (!articulations.size()) + cout << "nenhum" << ende; + else { + for (auto i : articulations) + cout << i + 1 << " "; + cout << ende; + } + + cas++; + cout << ende; + } + + return 0; +} diff --git a/contests/ICPC_SA17/a.out b/contests/ICPC_SA17/a.out deleted file mode 100755 index bfe686fe7a6b3981e10c013b2d82a356a7be7cf7..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 17200 zcmeHPe{@t;e!r6h2nxyYLq*YLMDPGEV<x`{x@ZzIFwp=p2}(tLPG(+`k;zPU<_#pY zw9%k-7FjvFc4e(?soP_<?Kz9KwYb~GAQs&{){}LurIq#Mbk$9iJ<`QRw8-@Hz3+Y} zZ(iml$l3j4&++2q`@Wz1{eJKF{=V<t`}`As)0zU8OK>O@Hwof~OH8CzMI5+MJ%H4T z8ZjMzzap*@Q^6NW%#5!!31ZD~Mww<>tnflm(yJ*j0Xw}?$uVUQiB3^*`AFksCdyO@ zj|51Md_AKKp1IP*nR>_}gu%c~=7Z8B_ejrul?l7A^2moQRsOpb<@{0J=+~xjJ8h6w zgkVat6q?^N!t~s5iDbvoHWL<1S?@OJk)P)q+)A)TrRP*G#j0GGQaMt%J{oDSuDm`P zULK9aQoYN2YpR!5S9+6iZ@J7j*(cex>o=0PATz2cWc*x(QT(-;M_*X~kB6qe^T?s^ zukp7Pe!hLm9Fm=nAJ-ddpuh!9!YIt$H)D13JJZ;t30nSs8!@vjJU{*i99hVWh3-T` z`Q%@Rd_FwkAb+Vtx~Gs<K06B?>>qZ(sWkK1dBFic;9zIi!T*1D@ZaYkzrn%&s}Az- zIQY2$xCcLbc+A264;}2k>mX0<(PK9bo`$u2c(X$}9EE(o@}GxvXNk*&$75P^!#@h& z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