STL  SET  QUESTION   SPOJ   FRIENDS OF  FRIEND




#include<bits/stdc++.h>

using namespace std;

int main()
{
int n,i,k,m,j;
cin>>n;

set<int> s;
for(i=0;i<n;i++)
{
cin>>k;
s.insert(k);
 cin>>m;
 for(j=0;j<m;j++)
 {
  cin>>k;
  s.insert(k);
 }
}
 //for (std::set<int>::iterator it=s.begin(); it!=s.end(); ++it)
   // std::cout << ' ' << *it;
 
    cout<<s.size()-n<<endl;
return 0;
}

Comments

Popular posts from this blog

Getting Started With MEAN App Development with AngularJs , ExpressJs , NodeJs and MongoDB.

B. Dreamoon and WiFi :calculate no. of ways : recursive solution (branch and bound )

A. Dreamoon and Stairs : minimum steps to reach : recursion solution.