poj 2503 查字典】的更多相关文章

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…
Babelfish Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 35828   Accepted: 15320 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…
输入若干组对应关系,然后输入应该单词,输出对应的单词,如果没有对应的输出eh 此题的做法非常多,很多人用了字典树,还有有用hash的,也有用了排序加二分的(感觉这种方法时间效率最差了),这里我参考了MSDN中stl,使用了map,map是基于红黑树的,查询和插入的时间复杂度都是log(n),如果你构造了一个好的哈希函数的或也可以把时间复制度降到很低.字典树应该是最快的方法了,不过结构相对来说比较复杂,代码不大容易编写(对我而言). 以下只给出我写的使用map的代码 #include <stdio…
时间限制: 1 s 空间限制: 16000 KB 题目等级 : 钻石 Diamond 题目描述 Description RY哥最近新买了一本字典,他十分高兴,因为这上面的单词都十分的和谐,他天天查字典. 输入描述 Input Description 1个整数N,表示字典里面的单词数量. 接下来N行,每行一个字符串,表示一个单词. 然后第N+2行,一个整数M,表示要查的单词数. 接下来M行,每行一个字符串,表示一个要查的单词. 输出描述 Output Description 对于每一个要查的单词,…
时间限制: 1 s  空间限制: 16000 KB  题目等级 : 钻石 Diamond  题目描述 Description RY哥最近新买了一本字典,他十分高兴,因为这上面的单词都十分的和谐,他天天查字典. 输入描述 Input Description 1个整数N,表示字典里面的单词数量. 接下来N行,每行一个字符串,表示一个单词. 然后第N+2行,一个整数M,表示要查的单词数. 接下来M行,每行一个字符串,表示一个要查的单词. 输出描述 Output Description 对于每一个要查的…
题目链接:http://codevs.cn/problem/2875/ 题目描述 Description RY哥最近新买了一本字典,他十分高兴,因为这上面的单词都十分的和谐,他天天查字典. 输入描述 Input Description 1个整数N,表示字典里面的单词数量. 接下来N行,每行一个字符串,表示一个单词. 然后第N+2行,一个整数M,表示要查的单词数. 接下来M行,每行一个字符串,表示一个要查的单词. 输出描述 Output Description 对于每一个要查的单词,如果在字典里面…
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…
题目链接:http://poj.org/problem?id=2503 题意:给定一个词典,输入格式为[string1' 'string2]  意思是string2的值为string1. 然后给定一波字符串问你该字符串在字典的值是多少? 思路:字典树模板题.  叶子结点存放的是对应词典中的值. #include<iostream> #include<algorithm> #include<cstring> #include<string> #include&…
题目链接:http://poj.org/bbs?problem_id=2503 思路分析: 题目数据数据量为10^5, 为查找问题,使用Hash或Map等查找树可以解决,也可以使用字典树查找. 代码(Map实现): #include <iostream> #include <sstream> #include <string> #include <map> using namespace std; int main() { ], foreignWord[],…
Babelfish Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 30816   Accepted: 13283 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…