• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            我希望你是我獨家記憶

            一段永遠封存的記憶,隨風而去
            posts - 263, comments - 31, trackbacks - 0, articles - 3
               :: 首頁 :: 新隨筆 ::  :: 聚合  :: 管理
            /*
            ID: wangzha4
            LANG: C++
            TASK: lgame
            */
            /*
               Test 1: TEST OK [0.032 secs, 3352 KB]
               Test 2: TEST OK [0.043 secs, 3348 KB]
               Test 3: TEST OK [0.065 secs, 3352 KB]
               Test 4: TEST OK [0.032 secs, 3352 KB]
               Test 5: TEST OK [0.043 secs, 3348 KB]
               Test 6: TEST OK [0.043 secs, 3348 KB]
               Test 7: TEST OK [0.043 secs, 3352 KB]
               Test 8: TEST OK [0.043 secs, 3352 KB]
               Test 9: TEST OK [0.043 secs, 3352 KB]
               Test 10: TEST OK [0.043 secs, 3352 KB]
               Test 11: TEST OK [0.032 secs, 3348 KB]
               Test 12: TEST OK [0.032 secs, 3348 KB]
            */
            #include 
            <stdio.h>
            #include 
            <stdlib.h>
            #include 
            <string.h>
            #include 
            <ctype.h>
            #define llong unsigned long long 
            #define unint unsigned int
            #define printline  printf( "\n" ) 

            const int INF = 1000000 ;
            const int size = 155 ;

            const int table[27= { 2,5,4,4,1,6,5,5,1,7,6,3,5,2,3,5,7,2,1,2,4,6,6,7,5,7 } ;
            char instr[27] ; 
            int len, val ;
            int flag[150= {0} ;

            struct DICT 
            {
                
            char str[8] ;
                
            int val ;
                
            int len ;
            };
            struct DICT dict[40005] ;
            int ct_dict = 0 ;

            char out[1000][10] ;
            int ct_out = 0 ;

            int bestval = -1 ;

            int cmp( const void *a, const void *b )
            {
                
            struct DICT *= (struct DICT *)a ;
                
            struct DICT *= (struct DICT *)b ;

                
            if( d->len != c->len )
                    
            return d->len - c->len ;
                
            else
                    
            return c->val - d->val ;
            }

            void init()
            {
                memset( flag, 
            0sizeof(flag) ) ;

                len 
            = strlen( instr ) ;
                
            forint i=0; i<len; i++ ) flag[instr[i]] ++ ;

                freopen( 
            "lgame.dict""r", stdin ) ; char indict[10] ;
                
            while( scanf( "%s", indict ) != EOF )
                {
                    
            if'.' == indict[0] )    break ;

                    
            int tflag[150= {0} ;
                    memset( tflag, 
            0sizeof(tflag) ) ;
                    
            int curlen = strlen( indict ) ; bool inword = true ;
                    
            forint i=0; i<curlen; i++ ) {
                        
            if!flag[indict[i]] )    { inword = false ; break ; }
                        tflag[indict[i]] 
            ++ ;
                        
            if( tflag[indict[i]] > flag[indict[i]] ) { inword = false ; break ; }
                    }
                    
            if( inword ) 
                    {
                        dict[ct_dict].len 
            = curlen ;
                        strcpy( dict[ct_dict].str, indict ) ;
                        dict[ct_dict].val 
            = 0 ;
                        
            forint i=0; i<curlen; i++ )
                            dict[ct_dict].val 
            += table[indict[i]-'a'] ;

                        ct_dict 
            ++ ;
                    }
                }

                qsort( dict, ct_dict, 
            sizeof(dict[0]), cmp ) ;
            }

            void process()
            {
                bestval 
            = -1 ; int tflag[150] ; int ttflag[150] ;
                
            forint i=0; i<ct_dict; i++ )
                {
                    
            if( dict[i].val > bestval )
                    {
                        bestval 
            = dict[i].val ;
                        ct_out 
            = 0 ;
                        strcpy( 
            out[ct_out++], dict[i].str ) ;
                    }
                    
            else if( dict[i].val == bestval )
                    {
                        strcpy( 
            out[ct_out++], dict[i].str ) ;
                    }
                    
            //else //注意這個地方不要用else
                    {
                        
            forint j=ct_dict-1; j>i; j-- )
                        {
                            
            if( dict[i].len + dict[j].len > len )    break ;
                            
            if( dict[i].val + dict[j].val < bestval )    continue ;
                            memset( tflag, 
            0sizeof(tflag) ) ;
                            memset( ttflag, 
            0sizeof(ttflag) ) ;
                            
            forint k=0; k<dict[i].len; k++ ) ttflag[dict[i].str[k]]++ ;
                            
            forint k=0; k<dict[j].len; k++ ) tflag[dict[j].str[k]] ++ ;
                            
            int curval = 0 ; bool canUnion = true ;
                            
            forint k=0; k<dict[j].len; k++ ) 
                            {
                                
            if( tflag[dict[j].str[k]] + ttflag[dict[j].str[k]] > flag[dict[j].str[k]] ) 
                                { canUnion 
            = false ; break ; }
                            }
                            
            if( canUnion )
                            {
                                curval 
            = dict[i].val + dict[j].val ;
                                
            if( curval > bestval )
                                {
                                    bestval 
            = curval ;
                                    ct_out 
            = 0 ;
                                    
            if( strcmp( dict[i].str, dict[j].str ) < 0 ) {
                                        strcpy( 
            out[ct_out], dict[i].str ) ;
                                        
            out[ct_out][dict[i].len] = ' ' ;
                                        
            out[ct_out][dict[i].len+1= '\0' ;
                                        strcat( 
            out[ct_out], dict[j].str ) ;
                                        ct_out
            ++ ;
                                    }
                                    
            else {
                                        strcpy( 
            out[ct_out], dict[j].str ) ;
                                        
            out[ct_out][dict[j].len] = ' ' ;
                                        
            out[ct_out][dict[j].len+1= '\0' ;
                                        strcat( 
            out[ct_out], dict[i].str ) ;
                                        ct_out
            ++ ;
                                    }
                                }
                                
            else if( curval == bestval )
                                {
                                    
            if( strcmp( dict[i].str, dict[j].str ) < 0 ) {
                                        strcpy( 
            out[ct_out], dict[i].str ) ;
                                        
            out[ct_out][dict[i].len] = ' ' ;
                                        
            out[ct_out][dict[i].len+1= '\0' ;
                                        strcat( 
            out[ct_out], dict[j].str ) ;
                                        ct_out
            ++ ;                    
                                    }
                                    
            else {
                                        strcpy( 
            out[ct_out], dict[j].str ) ;
                                        
            out[ct_out][dict[j].len] = ' ' ;
                                        
            out[ct_out][dict[j].len+1= '\0' ;
                                        strcat( 
            out[ct_out], dict[i].str ) ;
                                        ct_out
            ++ ;
                                    }
                                }
                            }
                        }
                    }
                }
            }


            int outcmp( const void *a, const void *b )
            {
                
            char *= (char *)a ; char *= (char *)b ;

                
            return strcmp( c, d ) ;
            }

            void output()
            {
                qsort( 
            out, ct_out, sizeof(out[0]), outcmp ) ;

                printf( 
            "%d\n",bestval ) ;
                
            forint i=0; i<ct_out; i++ ) printf( "%s\n"out[i] ) ;
            }

            int main()
            {
                freopen( 
            "lgame.in""r", stdin ) ;
                freopen( 
            "lgame.out","w",stdout ) ;

                
            while( scanf( "%s", instr ) != EOF )
                {
                    init() ;

                    process() ;

                    output() ;
                }

                
            return 0 ;
            }
            久久亚洲日韩看片无码| 韩国免费A级毛片久久| 亚洲欧洲久久久精品| 亚洲国产精品综合久久网络| 久久精品国产免费观看三人同眠| 久久w5ww成w人免费| 久久性生大片免费观看性| 国产精品99久久久精品无码| 国产日韩久久免费影院| 久久人人爽人人爽人人片av麻烦 | 亚洲&#228;v永久无码精品天堂久久 | 青青草原综合久久大伊人导航| 久久久久亚洲av成人网人人软件| 国产精品久久久久久吹潮| 无码任你躁久久久久久| 色综合久久中文色婷婷| 欧洲精品久久久av无码电影| 久久夜色撩人精品国产| 国产精品丝袜久久久久久不卡| 久久精品aⅴ无码中文字字幕重口| 欧美午夜A∨大片久久| 国产日韩久久久精品影院首页| www性久久久com| 日产精品久久久久久久| 久久这里只有精品首页| 亚洲午夜精品久久久久久app| 国产成人无码精品久久久久免费| AAA级久久久精品无码片| 久久久久久国产精品免费无码| 久久久无码精品亚洲日韩蜜臀浪潮| 久久久久一级精品亚洲国产成人综合AV区| 精品久久久久久亚洲| 国产99精品久久| 青青草原综合久久| 国内精品久久久久久久影视麻豆 | 久久亚洲国产午夜精品理论片| 久久亚洲精精品中文字幕| 久久综合香蕉国产蜜臀AV| 久久久久久久人妻无码中文字幕爆| 无码国内精品久久人妻蜜桃| 色欲综合久久中文字幕网|