ZOJ 1109 Language of FatMouse 【Trie树】】的更多相关文章

Language of FatMouse Time Limit: 10 Seconds      Memory Limit: 32768 KB We all know that FatMouse doesn't speak English. But now he has to beprepared since our nation will join WTO soon. Thanks to Turing we havecomputers to help him. Input Specificat…
<题目链接> 题目大意: 刚开始每行输入两个单词,第二个单词存入单词库,并且每行第二个单词映射着对应的第一个单词.然后每行输入一个单词,如果单词库中有相同的单词,则输出它对应的那个单词,否则输出“eh”. 解体分析: 本题是trie树的模板题,在建树的时候,在每个单词的结尾节点储存对应单词的序号即可.当然,本题用map也可做,但是效率不够高. #include<cstdio> #include<cstring> #include<iostream> #inc…
好开心,手动自己按照字典树的思想用c写了一个优化后的trie字典树,就是用链表来代替26个大小的字符数组.完全按照自己按照自己的想法打的,没有参考如何被人的代码.调试了一天,居然最后错在一个小问题上,郁闷啊!!!最后终于调试出来了!!一次提交就ac了!!开心溢于言表啊!!!!!! /* trie树: 插入: 插入一段字符串: 每个字符作为树的一层(同一层的节点通过兄弟节点项连),每个节点如果有后继节点的话,就把最大的后继放到其后面. 如果字符串结束,就在该节点处,connt++;然后用一个字符串…
题目连接: acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=1109 题目描述: We all know that FatMouse doesn't speak English. But now he has to be prepared since our nation will join WTO soon. Thanks to Turing we have computers to help him. Input Specifica…
Language of FatMouse Time Limit: 10 Seconds      Memory Limit: 32768 KB We all know that FatMouse doesn't speak English. But now he has to be prepared since our nation will join WTO soon. Thanks to Turing we have computers to help him. Input Specific…
较简单字典树,每输入一对字符串,前一个放在字典(数组)中,后一个插入字典树中,并将其最终的flag赋为前一个在数组中的下标,再就好找了.输入的处理方法要注意一下. 代码: #include <iostream> #include <cstdio> #include <cstring> #include <cmath> #include <algorithm> #include <string> #include <cstdlib…
题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=109 题目意思:给出一个mouse-english词典,问对于输入的mouse单词,能否在这个词典里找出对应的english,不能输出“eh” 这里用到map来做,value 保存 english,key保存mouse. #include <iostream> #include <cstdio> #include <cstdlib> #inc…
这道题目最让人头疼的就是该题的input怎么结束,因为它要求输入一个空行的时候则一串字符串输入结束,这就不得不让人绕个弯来解决这个问题. (注:本人习惯于使用C中的字符串操作,但是用到map要求使用string所以小绕弯) #include <map> #include <iostream> #include <string> #include <stdio.h> #include <string.h> #include <stdlib.h…
Language of FatMouse Time Limit: 10 Seconds      Memory Limit:32768 KB We all know that FatMouse doesn't speak English. But now he has to be prepared since our nation will join WTO soon. Thanks to Turing we have computers to help him. Input Specifica…
1.概述 Trie树,又称字典树,单词查找树或者前缀树,是一种用于快速检索的多叉树结构,如英文字母的字典树是一个26叉树,数字的字典树是一个10叉树. 我理解字典树是看了这位大佬博客.还不了解字典树的可以先进去学习一下 https://www.cnblogs.com/TheRoadToTheGold/p/6290732.html 还有这个讲了下为什么用字典树,和其他的相比优缺点在哪 https://www.cnblogs.com/Allen-rg/p/7128518.html 现在来个题来更进一…