diff --git a/contests/Cadernaveis/MANUT.cpp b/contests/Cadernaveis/MANUT.cpp new file mode 100644 index 0000000000000000000000000000000000000000..286be05135d00b5fad4b06ad6c19b47e3b6dc496 --- /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 Binary files a/contests/ICPC_SA17/a.out and /dev/null differ