Advertisement
Guest User

Untitled

a guest
Jan 27th, 2015
292
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using namespace std;
  2. int main(){
  3. int n,k;
  4. cin>>n>>k;
  5. set<int> l[n]; bool f[n];int s=0;
  6. for(int i=0;i<n;++i){f[i]=false;int p;cin>>p;for(int j=0;j<p;++j){int x;cin>>x;l[i].insert(x);}}
  7. f[0]=true;
  8. queue<int> q;
  9. q.push(0);
  10. f[0]=true;
  11. while(!q.empty()){
  12. int i = q.front();q.pop();// cout<<i<<endl;
  13. f[i]=true;
  14. ++s;
  15. for(int j=1;j<n;++j){if(f[j]==false){//cout<<"COMP: "<<j<<endl;
  16. vector<int> mve(300);
  17. vector<int>::iterator itr = set_intersection(l[j].begin(),l[j].end(),l[i].begin(),l[i].end(),mve.begin());
  18. mve.resize(itr-mve.begin());
  19. if(mve.size()>=k){ q.push(j);/*cout<<"ADD: "<<j<<". size = "<<mve.size()<<endl;*/}
  20. }}
  21. // getchar();
  22. }
  23.  
  24. cout<<s;
  25. return 0;
  26. }
Advertisement
RAW Paste Data Copied
Advertisement