摘要: http://poj.org/problem?id=2503 思路很简单,对foreign language word建trie树,插入时一并传入word的序号,与english word相对应。查找时直接查找word标记的序号,从存储数组中输出englishword就好了。 比较蛋疼的是这题的输入,一开始真心搞不定啊。。搞定后直接1Y。code:#include<cstdio>#include<cstring>charstr[100001][11];//模式串charestr[100001][11];#defineMAX26//字符集大小typedefstructTr 阅读全文
posted @ 2012-02-07 21:54 追逐. 阅读(187) 评论(0) 推荐(0) 编辑
摘要: 拿到这题,大致的画了画图,发现只要标记好每个节点出现的次数就好了。 插入时,若字符存在,n++,若不存在建立新节点,他本身也为自己的前缀。 查找时,若next[k]->nCount!=1,说明其子节点有多个,无法确定唯一,则输出该字符,若nCount=1,则可以结束查找了。code:#include<cstdio>#include<cstring>charstr[1001][21];#defineMAX30//字符集大小typedefstructTrieNode{intnCount;//记录该字符出现次数structTrieNode*next[MAX];}Trie 阅读全文
posted @ 2012-02-07 19:54 追逐. 阅读(135) 评论(0) 推荐(0) 编辑