• <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 ;
            }
            久久久久亚洲国产| 久久无码人妻一区二区三区午夜 | 久久久精品视频免费观看| 精品国产乱码久久久久久浪潮| 亚洲国产一成久久精品国产成人综合 | 婷婷久久综合九色综合98| 亚洲国产精品热久久| 深夜久久AAAAA级毛片免费看| 九九久久精品无码专区| 无码专区久久综合久中文字幕| 99久久99久久精品免费看蜜桃| 国产亚洲精午夜久久久久久| 色88久久久久高潮综合影院| 久久久精品人妻无码专区不卡 | segui久久国产精品| 亚洲精品午夜国产VA久久成人| 日本福利片国产午夜久久| 亚洲中文字幕无码久久综合网| 久久精品视频91| 亚洲乱亚洲乱淫久久| 久久99亚洲网美利坚合众国| 国内精品久久久久影院亚洲| 久久99国产精品成人欧美| 精品久久久久久| 久久Av无码精品人妻系列 | 国产成人综合久久精品尤物| 久久久久亚洲av无码专区| 精品久久久无码人妻中文字幕| 日本加勒比久久精品| 国内精品久久久久国产盗摄| 香港aa三级久久三级| 婷婷综合久久中文字幕| 久久久中文字幕| 97久久精品人人做人人爽| 青青草国产成人久久91网| 精品久久一区二区三区| 久久91精品国产91久久小草| 精品久久久久久中文字幕| 岛国搬运www久久| 久久AⅤ人妻少妇嫩草影院| 久久久久香蕉视频|