标签:time ret return name more space invite mic div
1 #define HAVE_STRUCT_TIMESPEC 2 #include<bits/stdc++.h> 3 using namespace std; 4 set<int>v[207]; 5 int a[207]; 6 int vis[207]; 7 int main(){ 8 ios::sync_with_stdio(false); 9 cin.tie(NULL); 10 cout.tie(NULL); 11 int n,m; 12 cin>>n>>m; 13 for(int i=1;i<=m;++i){ 14 int x,y; 15 cin>>x>>y; 16 v[x].insert(y); 17 v[y].insert(x); 18 } 19 int k; 20 cin>>k; 21 for(int i=1;i<=k;++i){ 22 int num; 23 cin>>num; 24 if(num==0){ 25 cout<<"Area "<<i<<" needs help."; 26 cout<<"\n"; 27 continue; 28 } 29 for(int j=1;j<=num;++j) 30 cin>>a[j]; 31 int flag=0; 32 for(int k=1;k<=num;++k){ 33 for(int j=1;j<=num;++j){ 34 if(k==j) 35 continue; 36 if(!v[a[k]].count(a[j])){ 37 flag=1; 38 } 39 } 40 } 41 if(flag){ 42 cout<<"Area "<<i<<" needs help."; 43 cout<<"\n"; 44 continue; 45 } 46 memset(vis,0,sizeof(vis)); 47 for(int j=1;j<=num;++j){ 48 for(auto it:v[a[j]]) 49 ++vis[it]; 50 } 51 int ans=0; 52 for(int j=1;j<=n;++j) 53 if(vis[j]==num){ 54 ans=j; 55 break; 56 } 57 if(ans){ 58 cout<<"Area "<<i<<" may invite more people, such as "<<ans<<"."; 59 cout<<"\n"; 60 continue; 61 } 62 cout<<"Area "<<i<<" is OK."; 63 cout<<"\n"; 64 } 65 return 0; 66 }
标签:time ret return name more space invite mic div
原文地址:https://www.cnblogs.com/ldudxy/p/12255730.html