Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cmath>
- #include <cstdio>
- #include <vector>
- #include <iostream>
- #include <algorithm>
- using namespace std;
- int number=0;
- int numberOf(vector<vector<int>> mygraph,int current,int n, vector<bool> visited)
- {
- vector<int> :: iterator itr;
- visited[current]=true;
- int count =1;
- for(itr=mygraph[current].begin();itr!=mygraph[current].end();itr++)
- {
- if(!visited[*itr])
- {
- count += numberOf(mygraph,*itr,n,visited);
- }
- }
- if(count%2==0)
- {
- number++;
- }
- return count;
- }
- int main() {
- /* Enter your code here. Read input from STDIN. Print output to STDOUT */
- int n;
- int m;
- cin>>n>>m;
- vector<vector<int>> mygraph(n);
- vector<bool> visited(n,false);
- for(int i=0;i<m;i++)
- {
- int from;
- int to;
- cin>>from>>to;
- mygraph[from-1].push_back(to-1);
- mygraph[to-1].push_back(from-1);
- }
- numberOf(mygraph,0,n,visited);
- cout<<number-1;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement