锘??xml version="1.0" encoding="utf-8" standalone="yes"?>狠狠精品久久久无码中文字幕 ,国产精品9999久久久久,国内精品久久久久久久影视麻豆http://www.shnenglu.com/MiYu/category/14730.html ______________鐧界櫧銇眿zh-cnSun, 24 Oct 2010 08:57:39 GMTSun, 24 Oct 2010 08:57:39 GMT60trie鏍?-璇﹁Вhttp://www.shnenglu.com/MiYu/archive/2010/10/23/131017.htmlMiYuMiYuSat, 23 Oct 2010 14:05:00 GMThttp://www.shnenglu.com/MiYu/archive/2010/10/23/131017.htmlhttp://www.shnenglu.com/MiYu/comments/131017.htmlhttp://www.shnenglu.com/MiYu/archive/2010/10/23/131017.html#Feedback0http://www.shnenglu.com/MiYu/comments/commentRss/131017.htmlhttp://www.shnenglu.com/MiYu/services/trackbacks/131017.html闃呰鍏ㄦ枃

MiYu 2010-10-23 22:05 鍙戣〃璇勮
]]>
鏋佸害 YM....鑷繁鐢╰rie鍐欎簡涓吉 map....( HDU 1075 )http://www.shnenglu.com/MiYu/archive/2010/08/25/124721.htmlMiYuMiYuWed, 25 Aug 2010 11:41:00 GMThttp://www.shnenglu.com/MiYu/archive/2010/08/25/124721.htmlhttp://www.shnenglu.com/MiYu/comments/124721.htmlhttp://www.shnenglu.com/MiYu/archive/2010/08/25/124721.html#Feedback0http://www.shnenglu.com/MiYu/comments/commentRss/124721.htmlhttp://www.shnenglu.com/MiYu/services/trackbacks/124721.html

MiYu鍘熷垱, 杞笘璇鋒敞鏄?: 杞澆鑷?nbsp;______________鐧界櫧銇眿    

 

榪欏嚑澶╀竴鐩村緢YM..... 綰犵粨.....  鍋氫釜姘撮 1075......WA N嬈?....YM.
(  寰堢畝鍗曠殑涓棰?  媯绱㈣緭鍏ョ殑涓叉槸鍚﹀瓨鍦? 瀛樺湪灝辨浛鎹㈣緭鍑? 涓嶅瓨鍦ㄧ洿鎺ヨ緭鍑哄氨鍙互浜?)
鏈鍚庢棤濂? 綰疌++ STL..榪囦簡, 鏃墮棿绔熺劧鐢ㄤ簡 1600+MS 榪樻槸 C++浜ょ殑,  G++瑕?400+MS,  涓?br style="word-wrap: break-word; line-height: normal; ">鏄庣櫧涓轟粈涔堟椂闂村樊閭d箞澶?  鐢╰rie 鍋氫簡嬈? 250MS...   鏀逛簡濂藉嚑嬈℃晥鐜囬兘涓婁笉鏉?nbsp;  ....  YM 涓?鎶妕rie 鍐欐垚浜?浼?map ,鍙湁涓鐐圭畝鍗曠殑鍔熻兘,
鍏朵粬鐨勪笉鎯沖啓浜?  鍐欏緱濂藉鏉?................... 
浼?map 浠g爜濡備笅 :  濂介暱.....................
/*
MiYu鍘熷垱, 杞笘璇鋒敞鏄?: 杞澆鑷?______________鐧界櫧銇眿
          http://www.cnblog.com/MiYu
Author By : MiYu
Test      : 4
Program   : 1075
*/

#include <iostream>
#include <string>
using namespace std;
typedef struct dict DIC;
DIC *root = NULL;
string ext = "";
struct dict {
       dict (){ str = "";memset ( child , 0 , sizeof ( child ) ); }
       ~dict () { }
       void del ( DIC * node );
       string & insert ( char *ins,char *key = NULL );
       string & find ( char *ins );
       string & operator [] ( char *a );
       string & operator = ( char *a );
       DIC *child[26];
       string str; 
};
void dict::del ( DIC * node )
{
     if ( node == NULL ) return;
     for ( int i = 0; i != 26; ++ i )
     {
          if ( node->child[i] != NULL )  del ( node->child[i] );
     }
     node->str = "";
     free ( node );  
}
string & dict::operator [] ( char *a )
{
       string &str = find ( a );
       if ( str == "" )
           return  insert ( a );  
       return str;
}
string & dict::operator = ( char *a )
{
      return this->str = a; 
}
string & dict::insert ( char *ins,char *key )
{
            DIC *cur = this,*now;
            int len = strlen ( ins );
            for ( int i = 0; i != len; ++ i )
            {
                  if ( cur->child[ ins[i] - 'a' ] != NULL ) 
                  {
                       cur = cur->child[ ins[i] - 'a' ];
                  }
                  else
                  {
                       now = new DIC;
                       cur->child[ ins[i] - 'a' ] = now;
                       cur = now;
                  }
            } 
            return cur->str;
}
string & dict::find ( char *ins )
{
            DIC *cur = this;
            int len = strlen ( ins );
            for ( int i = 0; i != len; ++ i )
            {
                 if ( cur->child[ ins[i] - 'a' ] != NULL )
                      cur = cur->child[ ins[i] - 'a' ];  
                 else
                      return ext; 
            } 
            return cur->str;
}
char words[3010],temp[12],t[12];
int main ()
{
    DIC dict;
    root = &dict;
    scanf ( "%s", t );
    while ( scanf ( "%s", t ), strcmp ( t, "END" ) != 0 )
    {
           scanf ( "%s", temp );
           dict[temp] = t;
    }
    scanf ( "%s", t );
    getchar();
    while ( gets ( words ) && strcmp ( words, "END" ) != 0 )
    {
           memset ( temp, 0, sizeof ( temp ) );
           int len = strlen ( words );
           for ( int i = 0,j = 0; i != len; ++ i )
           {
                if ( isalpha ( words[i] ) )
                {
                     temp[j++] = words[i];
                } 
                else 
                {
                     temp[j] = '\0';
                     string str = dict[ temp ];
                     if ( str == "" )
                          printf ( "%s",temp ); 
                     else
                          printf ( "%s",str.c_str() );
                     putchar ( words[i] );
                     j = 0; 
                }
           }
           putchar ( 10 );
    }
    return 0;
}

 

 STL 浠g爜濡備笅 :  濂界煭....

 /*

MiYu鍘熷垱, 杞笘璇鋒敞鏄?: 杞澆鑷?______________鐧界櫧銇眿

          http://www.cnblog.com/MiYu

Author By : MiYu

Test      : 1

Program   : 1075

*/


#include <iostream>

#include <string>

#include <map>

using namespace std;

string words,temp;

map < string , string > mp;

int main ()

{

    cin >> words;

    while ( cin >> words, words != "END" )

    {

           cin >> temp;

           mp[ temp ] = words;

    }

    cin >> words;

    getchar();

    while ( getline ( cin, words ) && words != "END" )

    {

           string out = "";

           int len = words.size();

           for ( int i = 0; i != len; ++ i )

           {

                if ( isalpha ( words[i] ) )

                {

                     out += words[i];

                } 

                else 

                {

                     if ( mp[out] == "" )

                          cout << out; 

                     else

                          cout << mp[out];

                     cout << words[i];

                     out = ""; 

                }

           }

           cout << endl;

    }

    return 0;

}


 

 

 

 



MiYu 2010-08-25 19:41 鍙戣〃璇勮
]]>
HDOJ 1800 HDU 1800 Phone List ACM 1800 IN HDUhttp://www.shnenglu.com/MiYu/archive/2010/08/25/124657.htmlMiYuMiYuWed, 25 Aug 2010 03:54:00 GMThttp://www.shnenglu.com/MiYu/archive/2010/08/25/124657.htmlhttp://www.shnenglu.com/MiYu/comments/124657.htmlhttp://www.shnenglu.com/MiYu/archive/2010/08/25/124657.html#Feedback0http://www.shnenglu.com/MiYu/comments/commentRss/124657.htmlhttp://www.shnenglu.com/MiYu/services/trackbacks/124657.html

MiYu鍘熷垱, 杞笘璇鋒敞鏄?: 杞澆鑷?nbsp;______________鐧界櫧銇眿    

 

棰樼洰鍦板潃:

      http://acm.hdu.edu.cn/showproblem.php?pid=1800 

棰樼洰鎻忚堪:

Problem Description

In the year 8888, the Earth is ruled by the PPF Empire . As the population growing , PPF needs to find more land for the newborns . Finally , PPF decides to attack Kscinow who ruling the Mars . Here the problem comes! How can the soldiers reach the Mars ? PPF convokes his soldiers and asks for their suggestions . “Rush … ” one soldier answers. “Shut up ! Do I have to remind you that there isn’t any road to the Mars from here!” PPF replies. “Fly !” another answers. PPF smiles :“Clever guy ! Although we haven’t got wings , I can buy some magic broomsticks from HARRY POTTER to help you .” Now , it’s time to learn to fly on a broomstick ! we assume that one soldier has one level number indicating his degree. The soldier who has a higher level could teach the lower , that is to say the former’s level > the latter’s . But the lower can’t teach the higher. One soldier can have only one teacher at most , certainly , having no teacher is also legal. Similarly one soldier can have only one student at most while having no student is also possible. Teacher can teach his student on the same broomstick .Certainly , all the soldier must have practiced on the broomstick before they fly to the Mars! Magic broomstick is expensive !So , can you help PPF to calculate the minimum number of the broomstick needed .
For example : 
There are 5 soldiers (A B C D E)with level numbers : 2 4 5 6 4;
One method :
C could teach B; B could teach A; So , A B C are eligible to study on the same broomstick.
D could teach E;So D E are eligible to study on the same broomstick;
Using this method , we need 2 broomsticks.
Another method:
D could teach A; So A D are eligible to study on the same broomstick.
C could teach B; So B C are eligible to study on the same broomstick.
E with no teacher or student are eligible to study on one broomstick.
Using the method ,we need 3 broomsticks.
……

After checking up all possible method, we found that 2 is the minimum number of broomsticks needed. 
 

Input
Input file contains multiple test cases. 
In a test case,the first line contains a single positive number N indicating the number of soldiers.(0<=N<=3000)
Next N lines :There is only one nonnegative integer on each line , indicating the level number for each soldier.( less than 30 digits);
 

Output
For each case, output the minimum number of broomsticks on a single line.
 

Sample Input
4 10 20 30 04 5 2 3 4 3 4
 

Sample Output
1 2
 

棰樼洰鍒嗘瀽:

 

鐩稿鏉ヨ榪欓鐢ㄥ瓧鍏告爲(wèi)鐨勬晥鐜囨瘮杈冮珮浜?....閬楁喚鐨勬槸鎴戠幇鍦ㄥ彧浼?xì)鍋氫竴浜涘瓧鍏告爲(wèi)鐨?姘撮....瀵瑰瓧鍏告爲(wèi)鐨勭悊瑙g幇鍦ㄨ繕涓嶆槸寰堝ソ......鎵浠?鍛靛懙

榪欓鎴戝氨鐩存帴絳涢夎繃浜?.......

 

浠g爜濡備笅:

 /*

MiYu鍘熷垱, 杞笘璇鋒敞鏄?: 杞澆鑷?______________鐧界櫧銇眿

          http://www.cnblog.com/MiYu

Author By : MiYu

Test      : 1

Program   : 1800

*/


#include <iostream>

#include <algorithm>

using namespace std;

int num[3002];

bool hash[3002];

bool cmp ( const int &a, const  int &b )

{

     return a > b; 

}

int main ()

{

    int N;

    while ( scanf ( "%d", &N ) != EOF )

    {

           memset ( num, 0, 12008 );

           memset ( hash, 0, 3002 );

           for ( int i = 0; i != N; ++ i )

                 scanf ( "%d",num + i );

           sort ( num, num + N, cmp );

           int nCount = 0;

           for ( int i = 0; i < N; ++ i )

           {

                 if ( !hash[i] )

                 {

                      nCount ++;

                      int j = i ,k = j+1;

                      hash[j] = true;

                      while ( k < N ) 

                      {

                            if ( !hash[k] && num[k] < num[j] )

                            {

                                 hash[k] = true;

                                 j = k;

                            }

                            k++;

                      } 

                 }

           } 

           printf ( "%d\n",nCount );

    }

    return 0;

}


 

 



MiYu 2010-08-25 11:54 鍙戣〃璇勮
]]>
HDOJ 1247 HDU 1247 Hat鈥檚 Words ACM 1247 IN HDUhttp://www.shnenglu.com/MiYu/archive/2010/08/25/124658.htmlMiYuMiYuWed, 25 Aug 2010 03:54:00 GMThttp://www.shnenglu.com/MiYu/archive/2010/08/25/124658.htmlhttp://www.shnenglu.com/MiYu/comments/124658.htmlhttp://www.shnenglu.com/MiYu/archive/2010/08/25/124658.html#Feedback0http://www.shnenglu.com/MiYu/comments/commentRss/124658.htmlhttp://www.shnenglu.com/MiYu/services/trackbacks/124658.html

MiYu鍘熷垱, 杞笘璇鋒敞鏄?: 杞澆鑷?nbsp;______________鐧界櫧銇眿    

 

棰樼洰鍦板潃 :

     http://acm.hdu.edu.cn/showproblem.php?pid=1247 

棰樼洰鎻忚堪:

Hat’s Words

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 1384    Accepted Submission(s): 506


Problem Description
A hat’s word is a word in the dictionary that is the concatenation of exactly two other words in the dictionary.
You are to find all the hat’s words in a dictionary.
 

Input
Standard input consists of a number of lowercase words, one per line, in alphabetical order. There will be no more than 50,000 words.
Only one case.
 

Output
Your output should contain all the hat’s words, one per line, in alphabetical order.
 

Sample Input
a ahat hat hatword hziee word
 

Sample Output
ahat hatword
 

棰樼洰鍒嗘瀽 :

  

        瀛楀吀鏍?wèi)鐨勯鐩? 榪欎釜棰樼殑鏂規(guī)硶姣旇緝鏆村姏,  鍦ㄨ緭鍏ョ殑鏃跺欏皢姣忎釜鍗曡瘝閮藉姞鍏ュ瓧鍏告爲(wèi),  騫剁敤鏁扮粍灝嗘墍鏈夌殑涓查兘瀛樿搗鏉ユ潵.

鍦ㄨ緭鍏ュ畬鎴愬悗,  瀵規(guī)瘡涓崟璇嶈繘琛屾媶鍒? 涔熷氨鏄毚鍔涙灇涓懼崟璇嶄笉鍚屼綅緗殑鍓嶅悗閮ㄥ垎, 鐪嬪湪瀛楀吀鏍?wèi)涓槸鍚﹀瓨鍦? 瀛樺湪鍗寵緭鍑?

涓嶈繃璨屼技鏁版嵁姣旇緝寮? 璇存槸鎸夊瓧鍏擱『搴忚緭鍑? 浣嗗叾瀹炰粬鐨勮緭鍏ユ湰灝辨槸鎸夊瓧鍏擱『搴忚緭鍏ョ殑, 鎵浠ュ皢鎺掑簭涔熼潰浜?, 鍛靛懙.

    鍙﹀,鍏跺疄榪欓鐢⊿TL 鍋氭洿綆鍗? 褰撶劧榪芥眰鏁堢巼闄ゅ.

trie 浠g爜:

 /*

MiYu鍘熷垱, 杞笘璇鋒敞鏄?: 杞澆鑷?______________鐧界櫧銇眿

          http://www.cnblog.com/MiYu

Author By : MiYu

Test      : 1

Program   : 1247

*/


#include <iostream>

#include <algorithm>

#include <string>

using namespace std;

typedef struct dictor DIC;

DIC *root = NULL;

struct dictor {

       dictor (){ exist = false; memset ( child , 0 , sizeof ( child ) ); }

       void insert ( char *ins );

       bool find ( const char *ins );

private:

       DIC *child[26];

       bool exist; 

};

void dictor::insert ( char *ins )

{

            DIC *cur = root,*now;

            int len = strlen ( ins );

            for ( int i = 0; i < len; ++ i )

            {

                  if ( cur->child[ ins[i] - 'a' ] != NULL ) 

                  {

                       cur = cur->child[ ins[i] - 'a' ];

                  }

                  else

                  {

                       now = new DIC;

                       cur->child[ ins[i] - 'a' ] = now;

                       cur = now;

                  }

            } 

            cur->exist = true;

}

bool dictor::find ( const char *ins )

{

            DIC *cur = root;

            int len = strlen ( ins );

            for ( int i = 0; i < len; ++ i )

            {

                 if ( cur->child[ ins[i] - 'a' ] != NULL )

                      cur = cur->child[ ins[i] - 'a' ];  

                 else

                      return false; 

            } 

            return cur->exist;

}

char words[50050][100];

char s1[100],s2[100];

DIC dict;

int main ()

{

    root = &dict;

    int n = 0;

    while ( scanf ( "%s",words[n] ) != EOF )

    {

            dict.insert ( words[n++] );

    }

    for ( int i = 0; i < n; ++ i )

    {

          int len = strlen ( words[i] );

          for ( int j = 1; j < len; ++ j )

          {

                memset ( s1, 0, sizeof ( s1 ) );

                memset ( s2, 0, sizeof ( s2 ) );

                strncpy ( s1, words[i], j );

                strcpy ( s2, words[i]+j );

                if ( dict.find ( s1 ) && dict.find ( s2 ) )

                {

                     printf ( "%s\n", words[i] );

                     break; 

                }

          }  

    }  

    //system ( "pause" );

    return 0;

}


STL  浠g爜 :

 

 /*

MiYu鍘熷垱, 杞笘璇鋒敞鏄?: 杞澆鑷?______________鐧界櫧銇眿

          http://www.cnblog.com/MiYu

Author By : MiYu

Test      : 2

Program   : 1247

*/


#include <iostream>

#include <string>

#include <map>

using namespace std;

map < string , int > mp;

string str[50005];

int main ()

{

    int n = 0;

    while ( cin >> str[n] ) mp[ str[n++] ] = 1;

    for ( int i = 0; i < n; ++ i )

    {

          unsigned len = str[i].size ();

          for ( unsigned j = 1; j < len; ++ j )

          {

               string s1 ( str[i], 0, j );

               string s2 ( str[i], j );

               if ( mp[s1] == 1 && mp[s2] == 1 )

               {

                    cout << str[i] << endl; 

                    break;

               }

          } 

    }

    return 0;

}


 

 



MiYu 2010-08-25 11:54 鍙戣〃璇勮
]]>
HDOJ 1671 HDU 1671 Phone List ACM 1671 IN HDUhttp://www.shnenglu.com/MiYu/archive/2010/08/25/124655.htmlMiYuMiYuWed, 25 Aug 2010 03:39:00 GMThttp://www.shnenglu.com/MiYu/archive/2010/08/25/124655.htmlhttp://www.shnenglu.com/MiYu/comments/124655.htmlhttp://www.shnenglu.com/MiYu/archive/2010/08/25/124655.html#Feedback0http://www.shnenglu.com/MiYu/comments/commentRss/124655.htmlhttp://www.shnenglu.com/MiYu/services/trackbacks/124655.html闃呰鍏ㄦ枃

MiYu 2010-08-25 11:39 鍙戣〃璇勮
]]>
HDOJ 1251 HDU 1251 緇熻闅鵑 ACM 1251 IN HDUhttp://www.shnenglu.com/MiYu/archive/2010/08/25/124654.htmlMiYuMiYuWed, 25 Aug 2010 03:38:00 GMThttp://www.shnenglu.com/MiYu/archive/2010/08/25/124654.htmlhttp://www.shnenglu.com/MiYu/comments/124654.htmlhttp://www.shnenglu.com/MiYu/archive/2010/08/25/124654.html#Feedback0http://www.shnenglu.com/MiYu/comments/commentRss/124654.htmlhttp://www.shnenglu.com/MiYu/services/trackbacks/124654.html

MiYu鍘熷垱, 杞笘璇鋒敞鏄?: 杞澆鑷?nbsp;______________鐧界櫧銇眿    

 

棰樼洰鍦板潃:

     http://acm.hdu.edu.cn/showproblem.php?pid=1251 

棰樼洰鎻忚堪:

緇熻闅鵑

Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 131070/65535 K (Java/Others)
Total Submission(s): 5025    Accepted Submission(s): 1853


Problem Description
Ignatius鏈榪戦亣鍒頒竴涓毦棰?鑰佸笀浜ょ粰浠栧緢澶氬崟璇?鍙湁灝忓啓瀛楁瘝緇勬垚,涓嶄細(xì)鏈夐噸澶嶇殑鍗曡瘝鍑虹幇),鐜板湪鑰佸笀瑕佷粬緇熻鍑轟互鏌愪釜瀛楃涓蹭負(fù)鍓嶇紑鐨勫崟璇嶆暟閲?鍗曡瘝鏈韓涔熸槸鑷繁鐨勫墠緙).
 

Input
杈撳叆鏁版嵁鐨勭涓閮ㄥ垎鏄竴寮犲崟璇嶈〃,姣忚涓涓崟璇?鍗曡瘝鐨勯暱搴︿笉瓚呰繃10,瀹冧滑浠h〃鐨勬槸鑰佸笀浜ょ粰Ignatius緇熻鐨勫崟璇?涓涓┖琛屼唬琛ㄥ崟璇嶈〃鐨勭粨鏉?絎簩閮ㄥ垎鏄竴榪炰覆鐨勬彁闂?姣忚涓涓彁闂?姣忎釜鎻愰棶閮芥槸涓涓瓧絎︿覆.

娉ㄦ剰:鏈鍙湁涓緇勬祴璇曟暟鎹?澶勭悊鍒版枃浠剁粨鏉?
 

Output
瀵逛簬姣忎釜鎻愰棶,緇欏嚭浠ヨ瀛楃涓蹭負(fù)鍓嶇紑鐨勫崟璇嶇殑鏁伴噺.
 

Sample Input
banana band bee absolute acm ba b band abc
 

Sample Output
2 3 1 0
 

 

 

棰樼洰鍒嗘瀽:

    鍒氬瀛楀吀鏍?,涔熷氨鏄?trie 鏍? 鏁欑▼寰堝鏄撶湅鏄庣櫧, 1251 鏄竴閬撳緢鏄庢樉鐨?妯℃澘棰? 鐪嬭繃 PPT 鍚?鐩存帴鏁蹭唬鐮?1A.

絎竴嬈″仛, 欏轟究浠嬬粛涓?trie鏍?:

瀛楀吀鏍?wèi)锛圱rie錛夋槸涓縐嶇敤浜庡揩閫熷瓧絎︿覆媯绱㈢殑澶氬弶鏍?wèi)缁撴瀯銆傚叾鍘熺悊鏄埄鐢ㄥ瓧絎︿覆鐨勫叕鍏卞墠緙鏉ラ檷浣庢椂絀哄紑閿,浠庤岃揪鍒版彁楂樼▼搴忔晥鐜囩殑鐩殑銆?/p>

銆銆瀹冩湁濡備笅綆鍗曠殑鎬ц川錛?/p>

銆銆銆銆(1) 鏍硅妭鐐逛笉鍖呭惈瀛楃淇℃伅錛?/p>

銆銆銆銆(3) 涓媯祄搴︾殑Trie鎴栬呬負(fù)絀猴紝鎴栬呯敱m媯祄搴︾殑Trie緇勬垚銆?/p>

銆銆 鎼滅儲瀛楀吀欏圭洰鐨勬柟娉曚負(fù)錛?/p>

銆銆銆銆(1) 浠庢牴緇撶偣寮濮嬩竴嬈℃悳绱紱

銆銆銆銆(2) 鍙栧緱瑕佹煡鎵懼叧閿瘝鐨勭涓涓瓧姣嶏紝騫舵牴鎹瀛楁瘝閫夋嫨瀵瑰簲鐨勫瓙鏍?wèi)銆銆銆銆銆銆騫惰漿鍒拌瀛愭爲(wèi)緇х畫榪涜媯绱紱

銆銆銆銆(3) 鍦ㄧ浉搴旂殑瀛愭爲(wèi)涓婏紝鍙栧緱瑕佹煡鎵懼叧閿瘝鐨勭浜屼釜瀛楁瘝錛?/p>

銆銆銆銆銆銆騫惰繘涓姝ラ夋嫨瀵瑰簲鐨勫瓙鏍?wèi)杩涜妫绱€?/p>

銆銆銆銆(4) 榪唬榪囩▼……

銆銆銆銆(5) 鍦ㄦ煇涓粨鐐瑰錛屽叧閿瘝鐨勬墍鏈夊瓧姣嶅凡琚彇鍑猴紝鍒欒鍙?/p>

銆銆銆銆銆銆闄勫湪璇ョ粨鐐逛笂鐨勪俊鎭紝鍗沖畬鎴愭煡鎵俱?/span>

浠g爜濡備笅 :

    褰撶劧涔熷彲浠ユ嬁鏉ュ仛妯℃澘 ,    

 /*

MiYu鍘熷垱, 杞笘璇鋒敞鏄?: 杞澆鑷?______________鐧界櫧銇眿

          http://www.cnblog.com/MiYu

Author By : MiYu

Test      : 1

Program   : 1251

*/


#include <iostream>

using namespace std;

typedef struct dict DIC;

struct dict {

       dict (){ n = 0; memset ( child , 0 , sizeof ( child ) ); }

       void insert ( char *ins )

       {

            DIC *cur = this,*now;

            int len = strlen ( ins );

            if ( len == 0 )  return ;

            for ( int i = 0; i != len; ++ i )

            {

                  if ( cur->child[ ins[i] - 'a' ] != NULL ) 

                  {

                       cur = cur->child[ ins[i] - 'a' ];

                       cur->n ++; 

                  }

                  else

                  {

                       now = new DIC;

                       cur->child[ ins[i] - 'a' ] = now;

                       now->n ++;

                       cur = now;

                  }

            } 

       }

       int find ( char *ins )

       {

            DIC *cur = this;

            int len = strlen ( ins );

            if ( 0 == len )  return 0;

            for ( int i = 0; i != len; ++ i )

            {

                 if ( cur->child[ ins[i] - 'a' ] != NULL )

                      cur = cur->child[ ins[i] - 'a' ];  

                 else

                      return 0; 

            } 

            return cur->n;

       }

private:

       DIC *child[26];

       int n; 

};

char word[11];

int main ()

{

    DIC dict;

    while ( gets ( word ), strcmp ( word, "") != 0 )

          dict.insert ( word );

    char qur[11];

    while ( scanf ( "%s",qur ) != EOF )

    {

          printf ( "%d\n",dict.find ( qur ) ); 

    }    

    return 0;

}


 

 



MiYu 2010-08-25 11:38 鍙戣〃璇勮
]]>
欧美久久久久久| 久久免费香蕉视频| MM131亚洲国产美女久久| 国产成人精品久久综合| 武侠古典久久婷婷狼人伊人| 久久久久久久精品成人热色戒 | 久久性生大片免费观看性| 久久天天躁狠狠躁夜夜不卡| 久久综合狠狠色综合伊人| 一本综合久久国产二区| 26uuu久久五月天| 久久九九久精品国产免费直播| 精品久久8x国产免费观看| 久久婷婷是五月综合色狠狠| 精品国产91久久久久久久| 无码人妻精品一区二区三区久久久| 国产精品欧美亚洲韩国日本久久 | 久久精品国产2020| 国产午夜精品久久久久九九| 久久夜色精品国产噜噜亚洲AV| 欧美久久久久久精选9999| 狠狠88综合久久久久综合网| 久久这里只有精品首页| 免费一级欧美大片久久网| 精品国产综合区久久久久久| 精品午夜久久福利大片| 久久久久人妻精品一区| 日韩精品久久无码人妻中文字幕| 久久亚洲国产最新网站| 中文字幕无码久久人妻| 一级a性色生活片久久无| 一级女性全黄久久生活片免费| 久久久久亚洲精品中文字幕| 久久精品国产亚洲av瑜伽| 国产—久久香蕉国产线看观看| 国产精品亚洲美女久久久| 国产精品VIDEOSSEX久久发布| 久久这里只有精品久久| 亚洲综合久久综合激情久久 | 亚洲精品tv久久久久久久久久| 久久亚洲电影|