• <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>

            我希望你是我獨家記憶

            一段永遠封存的記憶,隨風(fēng)而去
            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 ;
            }
            欧美伊香蕉久久综合类网站| 亚洲色大成网站WWW久久九九| 久久精品亚洲中文字幕无码麻豆| 色狠狠久久AV五月综合| 国产精品视频久久久| 久久精品国产色蜜蜜麻豆| 人妻无码精品久久亚瑟影视| 久久亚洲精品人成综合网| 精品久久综合1区2区3区激情| 青青草原综合久久大伊人| 久久精品国产99久久久| 久久久久九九精品影院| www性久久久com| 人妻无码精品久久亚瑟影视 | 亚洲精品乱码久久久久久| 久久精品国产亚洲AV无码麻豆| 国产精品伦理久久久久久| 欧洲人妻丰满av无码久久不卡| 国产激情久久久久影院小草| 久久久久久久久久久久中文字幕 | 久久久国产99久久国产一| 国产精品99精品久久免费| 狠狠色婷婷久久一区二区| 久久精品一区二区三区中文字幕| 99国产精品久久久久久久成人热| 亚洲欧美一区二区三区久久| 久久精品国产99久久丝袜| 国产精品欧美久久久天天影视 | 久久久久亚洲精品天堂久久久久久| 久久亚洲精精品中文字幕| 久久99精品久久久大学生| 女人高潮久久久叫人喷水| 亚洲欧美成人久久综合中文网 | 热久久视久久精品18| 青青草原综合久久| 久久国产高潮流白浆免费观看| 久久精品久久久久观看99水蜜桃| 欧美与黑人午夜性猛交久久久| 99久久亚洲综合精品网站| 狠狠色丁香婷婷综合久久来 | 一极黄色视频久久网站|