poj 2503 Babelfish (查找 map)】的更多相关文章

题目:http://poj.org/problem?id=2503 不知道为什么 poj  的 数据好像不是100000,跟周赛的不一样 2000MS的代码: #include <iostream> #include<cstdio> #include<cstring> #include<cstdlib> #include<stack> #include<queue> #include<iomanip> #include&l…
题意:先构造一个词典,然后输入外文单词,输出相应的英语单词. 这道题有4种方法可以做: 1.map 2.字典树 3.快排+二分 4.hash表 参考博客:[解题报告]POJ_2503 字典树,MAP 参考博客:POJ2503两种解法:快速排序+二分查找与哈希表 思路1:可以使用map来做 代码: #include<iostream> #include<stdio.h> #include<string> #include<map> using namespac…
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/bbs?problem_id=2503 思路分析: 题目数据数据量为10^5, 为查找问题,使用Hash或Map等查找树可以解决,也可以使用字典树查找. 代码(Map实现): #include <iostream> #include <sstream> #include <string> #include <map> using namespace std; int main() { ], foreignWord[],…
一.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 e…
输入若干组对应关系,然后输入应该单词,输出对应的单词,如果没有对应的输出eh 此题的做法非常多,很多人用了字典树,还有有用hash的,也有用了排序加二分的(感觉这种方法时间效率最差了),这里我参考了MSDN中stl,使用了map,map是基于红黑树的,查询和插入的时间复杂度都是log(n),如果你构造了一个好的哈希函数的或也可以把时间复制度降到很低.字典树应该是最快的方法了,不过结构相对来说比较复杂,代码不大容易编写(对我而言). 以下只给出我写的使用map的代码 #include <stdio…
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…
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…
Babelfish Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 36967   Accepted: 15749 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…
Babelfish Time Limit: 3000MS Memory Limit: 65536K Total Submissions: 28766 Accepted: 12407 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 d…
题目链接 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 dictionar…
Time Limit: 3000MS Memory Limit: 65536K Total Submissions: 29059 Accepted: 12565 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…
1.Link: http://poj.org/problem?id=2503 http://bailian.openjudge.cn/practice/2503/ 2.Content: Babelfish Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 32783   Accepted: 14093 Description You have just moved from Waterloo to a big city. T…
题目链接:http://poj.org/problem?id=2153 思路分析: 判断Li Ming的成绩排名,需要在所有的数据章查找成绩比其高的人的数目,为查找问题. 查找问题可以使用Hash表,STL中的Map,查找树,或者使用排序与二分查找即可. 代码: #include <iostream> #include <map> #include <string> using namespace std; int main() { int personNum, exa…
[题目链接] http://poj.org/problem?id=2503 [算法] 字符串哈希 [代码] #include <algorithm> #include <bitset> #include <cctype> #include <cerrno> #include <clocale> #include <cmath> #include <complex> #include <cstdio> #incl…
各种方式解这道题!! 利用map 超时了 #include <iostream> #include <string> #include <map> using namespace std; string s; map<string,int> in; int main() { in.clear(); ,num=; ][]; ],b[],c[]; char ch=getchar(); while(ch!='\n') { ; while(ch>='a' &a…
Sample Input dog ogdaycat atcaypig igpayfroot ootfrayloops oopslay atcayittenkayoopslaySample Output catehloops 大致题意:输入一个字典,字典格式为“英语à外语”的一一映射关系然后输入若干个外语单词,输出他们的 英语翻译单词,如果字典中不存在这个单词,则输出“eh” 输入时顺便用STL的map标记外语是否出现过,然后再用map建立“外语à英语”的映射,那么输出时先查找“出现”的标记,若有…
题 给定字典,再询问. 字典与询问之间有一个空行. cin.peek()是一个指针指向当前字符. #include<iostream> #include<string> #include<map> using namespace std; map<string, string>dic; string s, t; int f; int main() { ios::sync_with_stdio(false); while(cin >> s) if(…
大致题意: 输入一个字典,字典格式为“英语à外语”的一一映射关系 然后输入若干个外语单词,输出他们的 英语翻译单词,如果字典中不存在这个单词,则输出“eh” #include<iostream> #include<cstdio> #include<map> #include<string> #include<cstring> using namespace std; int main() { map<string,string> ma…
字典树简单题. #include <cstdio> #include <cstring> #include <cstdlib> typedef struct Trie { Trie *next[]; ]; } Trie; Trie root; void create(char str[], char des[]) { , j, id; Trie *p = &root, *q; while (str[i]) { id = str[i] - 'a'; if (p-&…
http://poj.org/problem?id=2503 题意:就是翻译,给你一个字典,然后再查找单词,找得到的就输出单词,找不到的输出eh,用Map水题一个,但这个题有点意思的就是输入的问题 #include <iostream> #include <map> #include <string> #include <cstdio> using namespace std; int main() { // freopen("in.txt&quo…
http://poj.org/problem?id=2503 题意就是字典翻译.这个输入输出真心恶心,要不是看discuss我肯定是解决不了,还用上了sscanf函数.... 这道题我用几种方法做. sscanf与scanf类似,都是用于输入的,只是后者以屏幕(stdin)为输入源,前者以固定字符串为输入源. 一 qsort+二分 //Memory:5060K c++run time:422MS #include <stdio.h> #include <iostream> #inc…
题目链接:http://poj.org/problem?id=2503 题意:给定一个词典,输入格式为[string1' 'string2]  意思是string2的值为string1. 然后给定一波字符串问你该字符串在字典的值是多少? 思路:字典树模板题.  叶子结点存放的是对应词典中的值. #include<iostream> #include<algorithm> #include<cstring> #include<string> #include&…
Description Consider equations having the following form: a1x13+ a2x23+ a3x33+ a4x43+ a5x53=0 The coefficients are given integers from the interval [-50,50]. It is consider a solution a system (x1, x2, x3, x4, x5) that verifies the equation, xi∈[-50,…
题目:http://poj.org/problem?id=2418 在poj 上交题总是有各种错误,再次感叹各个编译器. c++ AC代码,G++为超时,上代码: #include<cstdio> #include<string> #include<map> using namespace std; ]; int main() { map<string,int>mp; map<string,int>::iterator iter;//声明迭代器…
题目链接:http://poj.org/problem?id=2503 代码: #include<cstdio> #include<cstring> #include<iostream> #include<algorithm> using namespace std; ; ; int head[HASH],next[maxn]; ],s2[maxn][]; int n; int hash(char *s) { ; ; while(*s) { ret = re…
分块查找算法 #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> using namespace std; +; ; //块的大小 ]; ]; ]; bool isPre(char mo[],char so[]) { ,j=; while(mo[i]&&so[j]) { if(mo[i]!=so[j]) return false; i++; j++…
Optimal Milking Time Limit: 2000MS Memory Limit: 30000K Total Submissions: 13968 Accepted: 5044 Case Time Limit: 1000MS Description FJ has moved his K (1 <= K <= 30) milking machines out into the cow pastures among the C (1 <= C <= 200) cows.…
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…
title: 487-3279 map POJ1002 tags: [map] 题目链接 Description Businesses like to have memorable telephone numbers. One way to make a telephone number memorable is to have it spell a memorable word or phrase. For example, you can call the University of Wat…