题目连接: 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…
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…
题目链接: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…
较简单字典树,每输入一对字符串,前一个放在字典(数组)中,后一个插入字典树中,并将其最终的flag赋为前一个在数组中的下标,再就好找了.输入的处理方法要注意一下. 代码: #include <iostream> #include <cstdio> #include <cstring> #include <cmath> #include <algorithm> #include <string> #include <cstdlib…
好开心,手动自己按照字典树的思想用c写了一个优化后的trie字典树,就是用链表来代替26个大小的字符数组.完全按照自己按照自己的想法打的,没有参考如何被人的代码.调试了一天,居然最后错在一个小问题上,郁闷啊!!!最后终于调试出来了!!一次提交就ac了!!开心溢于言表啊!!!!!! /* trie树: 插入: 插入一段字符串: 每个字符作为树的一层(同一层的节点通过兄弟节点项连),每个节点如果有后继节点的话,就把最大的后继放到其后面. 如果字符串结束,就在该节点处,connt++;然后用一个字符串…
题目链接: http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=2104 题目描述: Contest time again! How excited it is to see balloons floating around. But to tell you a secret, the judges' favorite time is guessing the most popular problem. When the co…
map映照容器的元素数据是一个键值和一个映照数据组成的,键值与映照数据之间具有一一映照的关系. map映照容器的数据结构是采用红黑树来实现的,插入键值的元素不允许重复,比较函数只对元素的键值进行比较,元素的各项数据可通过键值检索出来. 使用map容器需要头文件包含语句“#include<map>”, map文件也包含了对multimap多重映照容器的定义. .map创建.元素插入和遍历访问 创建map对象,键值与映照数据的类型由自己定义.在没有指定比较函数时,元素的插入位置是按键值由小到大插入…
map映照容器可以实现各种不同类型数据的对应关系,有着类似学号表的功能. 今天在做并查集的训练时,就用上了map映照容器. 题目就不上了,直接讲一下用法.顺便说一下,实现过程是在C++的条件下. #include<stdio.h> #include<string>//不能用string.h,因为那是C的字符串函数库,而map是在C++下的 #include<iostream> #include<map> using namespace std; 以上是必要的…