Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
跪求高手gaosu我我哪里错了//MY #include<set> #include<iterator> #include<iostream> #include<stdio.h> #include<vector> using namespace std; set<int>all; vector< set<int> >vs; int main() { //freopen("in.txt","r",stdin); int n,m; while(cin>>n>>m&&(n||m)) { if(m>n) {cout<<0<<endl;continue;} if(m==0){ cout<<1<<endl;continue; } all.clear(); int i; int flag=-1; vs.clear(); for(i=0;i<m;i++) { int tmp; cin>>tmp; int j; set<int>tmppp; vs.push_back(tmppp); if(!tmppp.empty()) tmppp.clear(); for(j=1;j<=tmp;j++) { int tmp2; cin>>tmp2; if(!tmp2) flag=i; vs[i].insert(tmp2); } } if(flag==-1) {cout<<1<<endl;continue;} set<int>::iterator it=vs[flag].begin(); for(;it!=vs[flag].end();it++) { all.insert(*it); //cout<<"*it:"<<*it<<' '; } //cout<<endl; for(i=0;i<m;i++) { if(i==flag) continue; for(it=vs[i].begin();it!=vs[i].end();it++) { if(all.count(*it)>0) { for(it=vs[i].begin();it!=vs[i].end();it++) { all.insert(*it); } break; } } } cout<<all.size()<<endl; } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator