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 |
so easy 不用任何算法,果断贴代码#include<iostream> #include<cstring> #include<cstdio> using namespace std; int main() { int n; int map[27]; bool target[27][27]; char a[27]; while(cin>>n&&n!=0) { memset(target,false,sizeof(target)); memset(map,0,sizeof(map)); for(int i=1; i<=n; i++) { cin>>a; for(int j=2; a[j]!='\0'; j++) { target[i][a[j]-'A'+1]=true; } } int c[27]= {0}; for(int i=1; i<=n; i++) { memset(c,0,sizeof(c)); for(int j=1; j<=n; j++) { if(target[i][j]) { c[map[j]]=1; } } for(int j=1; j<=n; j++ ) { if(c[j]==0) { map[i]=j; break; } } } int max=0; for(int i=1; i<=n; i++) { if(map[i]>max) { max=map[i]; } } if(max>1) { cout<<max<<" channels needed."<<endl; } else { cout<<max<<" channel needed."<<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