POJ2503-Babelfish-二分】的更多相关文章

Babelfish DescriptionYou have just moved from Waterloo to a big city. The people here speak an incomprehensible dialect of a foreign language. Fortunately, you have a dictionary to help you understand them.InputInput consists of up to 100,000 diction…
Babelfish Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 37238   Accepted: 15879 Description You have just moved from Waterloo to a big city. The people here speak an incomprehensible dialect of a foreign language. Fortunately, you have…
POJ2503 这是一道水题,用Map轻松AC. 不过,可以拿来测一下字符串散列, 毕竟,很多情况下map无法解决的映射问题需要用到字符串散列. 自己生成一个质数, 随便搞一下. #include<iostream> #include<cstdio> #include<cstdlib> #include<cstring> #include<string.h> #include<cmath> #include<vector>…
Description You have just moved from Waterloo to a big city. The people here speak an incomprehensible dialect of a foreign language. Fortunately, you have a dictionary to help you understand them. Input Input consists of up to 100,000 dictionary ent…
题目链接. 分析: 应当用字典树,但stl的map做很简单. #include <iostream> #include <cstdio> #include <cstdlib> #include <string> #include <algorithm> #include <vector> #include <map> #include <cstring> #include <queue> using…
思路:就是用一个字典树翻译单词的问题,我们用题目中给出的看不懂的那些单词建树,这样到每个单词的叶子结点中存放原来对应的单词就好. 这样查询到某个单词时输出叶子结点存的就行,查不到就"en"呗.这题用hash也是可以的 #include<iostream> #include<cstdio> #include<stdio.h> #include<cstring> #include<cmath> #include<vector…
题目链接poj2503 Babelfish Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 38820   Accepted: 16578 Description You have just moved from Waterloo to a big city. The people here speak an incomprehensible dialect of a foreign language. Fortunate…
题意:先构造一个词典,然后输入外文单词,输出相应的英语单词. 这道题有4种方法可以做: 1.map 2.字典树 3.快排+二分 4.hash表 参考博客:[解题报告]POJ_2503 字典树,MAP 参考博客:POJ2503两种解法:快速排序+二分查找与哈希表 思路1:可以使用map来做 代码: #include<iostream> #include<stdio.h> #include<string> #include<map> using namespac…
Babelfish Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 28581   Accepted: 12326 题目链接:http://poj.org/problem?id=2503 Description You have just moved from Waterloo to a big city. The people here speak an incomprehensible dialect of a for…
输入若干组对应关系,然后输入应该单词,输出对应的单词,如果没有对应的输出eh 此题的做法非常多,很多人用了字典树,还有有用hash的,也有用了排序加二分的(感觉这种方法时间效率最差了),这里我参考了MSDN中stl,使用了map,map是基于红黑树的,查询和插入的时间复杂度都是log(n),如果你构造了一个好的哈希函数的或也可以把时间复制度降到很低.字典树应该是最快的方法了,不过结构相对来说比较复杂,代码不大容易编写(对我而言). 以下只给出我写的使用map的代码 #include <stdio…