Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #define N 30005
- using namespace std;
- int disc[N], low[N];
- vector<int >A[N];
- int n, nr,ct;
- void DFS(int u, int p)
- {
- disc[u]=low[u]=++nr;
- int w;
- for(int i=0;i<A[u].size();i++)
- {
- w=A[u][i];
- if(w==p)continue;
- if(disc[w])low[u]=min(low[u],disc[w]);
- else
- {
- DFS(w,u);
- low[u]=min(low[u],low[w]);
- if(low[w]>disc[u])ct++;
- }
- }
- }
- void Citire()
- {
- cin>>n;
- int x,y;
- for(int i=1;i<=n;i++)
- {
- cin>>x>>y;
- A[x].push_back(y);
- A[y].push_back(x);
- }
- DFS(1,0);
- cout<<n-ct;
- }
- int main()
- {
- Citire();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement