锘??xml version="1.0" encoding="utf-8" standalone="yes"?> MiYu鍘熷垱, 杞笘璇鋒敞鏄?: 杞澆鑷?nbsp;______________鐧界櫧銇眿 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鍘熷垱, 杞笘璇鋒敞鏄?: 杞澆鑷?nbsp;______________鐧界櫧銇眿 棰樼洰鍦板潃: http://acm.hdu.edu.cn/showproblem.php?pid=1800 棰樼洰鎻忚堪: 棰樼洰鍒嗘瀽: 鐩稿鏉ヨ榪欓鐢ㄥ瓧鍏告爲(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鍘熷垱, 杞笘璇鋒敞鏄?: 杞澆鑷?nbsp;______________鐧界櫧銇眿 棰樼洰鍦板潃 : http://acm.hdu.edu.cn/showproblem.php?pid=1247 棰樼洰鎻忚堪: 棰樼洰鍒嗘瀽 : 瀛楀吀鏍?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鍘熷垱, 杞笘璇鋒敞鏄?: 杞澆鑷?nbsp;______________鐧界櫧銇眿 棰樼洰鍦板潃: http://acm.hdu.edu.cn/showproblem.php?pid=1251 棰樼洰鎻忚堪: 鍒氬瀛楀吀鏍?,涔熷氨鏄?trie 鏍? 鏁欑▼寰堝鏄撶湅鏄庣櫧, 1251 鏄竴閬撳緢鏄庢樉鐨?妯℃澘棰? 鐪嬭繃 PPT 鍚?鐩存帴鏁蹭唬鐮?1A. 絎竴嬈″仛, 欏轟究浠嬬粛涓?trie鏍?: 瀛楀吀鏍?wèi)锛圱rie錛夋槸涓縐嶇敤浜庡揩閫熷瓧絎︿覆媯(gè)绱㈢殑澶氬弶鏍?wèi)缁撴瀯銆傚叾鍘熺悊鏄埄鐢ㄥ瓧絎︿覆鐨勫叕鍏卞墠緙鏉ラ檷浣庢椂絀哄紑閿,浠庤岃揪鍒版彁楂樼▼搴忔晥鐜囩殑鐩殑銆?/p> 銆銆瀹冩湁濡備笅綆鍗曠殑鎬ц川錛?/p> 銆銆銆銆(1) 鏍硅妭鐐逛笉鍖呭惈瀛楃淇℃伅錛?/p> 銆銆銆銆(3) 涓媯祄搴︾殑Trie鎴栬呬負(fù)絀猴紝鎴栬呯敱m媯祄搴︾殑Trie緇勬垚銆?/p> 銆銆 鎼滅儲瀛楀吀欏圭洰鐨勬柟娉曚負(fù)錛?/p> 銆銆銆銆(1) 浠庢牴緇撶偣寮濮嬩竴嬈℃悳绱紱 銆銆銆銆(2) 鍙栧緱瑕佹煡鎵懼叧閿瘝鐨勭涓涓瓧姣嶏紝騫舵牴鎹瀛楁瘝閫夋嫨瀵瑰簲鐨勫瓙鏍?wèi)銆銆銆銆銆銆騫惰漿鍒拌瀛愭爲(wèi)緇х畫榪涜媯(gè)绱紱 銆銆銆銆(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; }
]]>
( 寰堢畝鍗曠殑涓棰? 媯(gè)绱㈣緭鍏ョ殑涓叉槸鍚﹀瓨鍦? 瀛樺湪灝辨浛鎹㈣緭鍑? 涓嶅瓨鍦ㄧ洿鎺ヨ緭鍑哄氨鍙互浜?)
鏈鍚庢棤濂? 綰疌++ 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爜濡備笅 : 濂介暱.....................![]()
]]>

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.
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);
]]>
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
You are to find all the hat’s words in a dictionary.
Only one case.
]]>
]]>
緇熻闅鵑
Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 131070/65535 K (Java/Others)
Total Submission(s): 5025 Accepted Submission(s): 1853
娉ㄦ剰:鏈鍙湁涓緇勬祴璇曟暟鎹?澶勭悊鍒版枃浠剁粨鏉?
]]>