Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Network UVa
#include<bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define pii pair<int,int> #define ff first #define ss second const int N = 1e3; vector<int> g[N]; vector<bool> vis(N); vector<int> tin(N) , low(N); int timer = 0; set<int> S; void dfs(int v, int p) { vis[v] = 1; low[v] = tin[v] = timer++; int children = 0; for(auto it : g[v]) { if(it == p) continue; else if(vis[it]) { low[v] = min(low[v],tin[it]); } else { dfs(it,v); low[v] = min(low[v] , low[it]); if(low[it] >=tin[v] && p!=-1) S.insert(v); ++children; } } if(p==-1 && children>1) S.insert(v); } int main() { ll n; while(cin >> n) { if(n==0) break; S.clear(); timer = 0; for(int i=0;i<N;i++) g[i].clear(); for(int i=0;i<N;i++) vis[i]=0; ll m; while(cin >> m) { if(m==0) break; string s; getline(cin,s); stringstream pp; pp << s; int xx; while(pp >> xx) { g[m].push_back(xx); g[xx].push_back(m); } } for(int i=1;i<=n;i++) if(vis[i]==0) dfs(i,-1); cout << S.size() << "\n"; } }
run
|
edit
|
history
|
help
0
Base File.cpp
Изволов#7
pi with cmath
My Tuple class
OverloadFunc
Stock buy/sell, maximum subarray problem
Virtuals
series kv type 1
D.E.Shaw Binary Search Question
Function to m_function