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

Re:四色定理+邻接矩阵+枚举 献丑了

Posted by ry951111 at 2014-11-07 10:47:05 on Problem 1129
In Reply To:四色定理+邻接矩阵+枚举 献丑了 Posted by:jndx20111221395 at 2013-02-02 20:33:52
> #include<cstdio>
> #include<cstring>
> 
> bool rela[26][26];
> char str[28] , ans , color[26];
> 
> char fun( char size )
> {
>     int i , j , k;
>     memset( rela , 0 , sizeof( rela ) );
>     memset( color , 1 , sizeof( color ) );
>     ans = 1;
>     for( i = 0 ; i < size ; i++ )
>     {
>         scanf("%s" , str );
>         for( j = 2 ; str[ j ] >= 'A' ; j++ )
>             rela[ i ][ str[ j ] - 'A' ] = 1;
>     }
>     for( k = 1 ; k < 4 ; k++ )
>         for( i = 0 ; i < size ; i++ )
>             if( color[ i ] == k )
>                 for( j = i+1 ; j < size ; j++ )
>                     if( rela[ i ][ j ] && color[ j ] == k )
>                         color[ j ] = k+1;
>     for( i = 1 , ans = color[0] ; i < size ; i++ )
>         if( color[ i ] > ans )
>             ans = color[ i ];
>     printf("%d channel%sneeded.\n" , ans , ans == 1 ? " " : "s " );
> }
> 
> int main()
> {
>     char size;
>     while( scanf("%d" , &size ) , size )
>         fun( size );
>     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