STL simply makes life easier!!!!
used set stl...................
Counted all non duplicates and then subtracted up by no. of friends of Bob
Code#
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin>>n;
set<int> myset;
set<int>::iterator it;
pair<set<int>::iterator,bool> w;
w=myset.insert(0);
if(w.second==true)
it=w.first;
for(int i=0;i<n;i++)
{
int x;
cin>>x;
myset.insert(it,x);
int num;
cin>>num;
for(int j=0;j<num;j++)
{
int y;
cin>>y;
myset.insert(it,y);
}
}
int count=0;
for(it=myset.begin();it!=myset.end();it++)
count++;
cout<<count-(n+1)<<endl;
// your code goes here
return 0;
}
used set stl...................
Counted all non duplicates and then subtracted up by no. of friends of Bob
Code#
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin>>n;
set<int> myset;
set<int>::iterator it;
pair<set<int>::iterator,bool> w;
w=myset.insert(0);
if(w.second==true)
it=w.first;
for(int i=0;i<n;i++)
{
int x;
cin>>x;
myset.insert(it,x);
int num;
cin>>num;
for(int j=0;j<num;j++)
{
int y;
cin>>y;
myset.insert(it,y);
}
}
int count=0;
for(it=myset.begin();it!=myset.end();it++)
count++;
cout<<count-(n+1)<<endl;
// your code goes here
return 0;
}
No comments:
Post a Comment