Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

so easy 不用任何算法,果断贴代码

Posted by 130428199210122910 at 2013-01-18 14:22:52 on Problem 1129
#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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator