【POJ 2503】Babelfish(字符串)】的更多相关文章

题目: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…
题目链接: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…
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…
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…
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…
一.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…
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…
题目链接 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…
题意:先构造一个词典,然后输入外文单词,输出相应的英语单词. 这道题有4种方法可以做: 1.map 2.字典树 3.快排+二分 4.hash表 参考博客:[解题报告]POJ_2503 字典树,MAP 参考博客:POJ2503两种解法:快速排序+二分查找与哈希表 思路1:可以使用map来做 代码: #include<iostream> #include<stdio.h> #include<string> #include<map> using namespac…
输入若干组对应关系,然后输入应该单词,输出对应的单词,如果没有对应的输出eh 此题的做法非常多,很多人用了字典树,还有有用hash的,也有用了排序加二分的(感觉这种方法时间效率最差了),这里我参考了MSDN中stl,使用了map,map是基于红黑树的,查询和插入的时间复杂度都是log(n),如果你构造了一个好的哈希函数的或也可以把时间复制度降到很低.字典树应该是最快的方法了,不过结构相对来说比较复杂,代码不大容易编写(对我而言). 以下只给出我写的使用map的代码 #include <stdio…
POJ 1159 Palindrome(字符串变回文:LCS) id=1159">http://poj.org/problem? id=1159 题意: 给你一个字符串, 问你做少须要在该字符串中插入几个字符能是的它变成一个回文串. 分析: 首先把原字符串和它的逆串进行匹配, 找出最长公共子序列. 那么最长公共子序列的字符串肯定是一个回文串. 所以原串剩下的部分是不构成回文的. 我们仅仅须要加入剩下部分的字符到相应位置, 原串自然就变成了一个回文. 所以本题的解为: n 减去 (原串与逆串…
题 给定字典,再询问. 字典与询问之间有一个空行. 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(…
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=2503 [算法] 字符串哈希 [代码] #include <algorithm> #include <bitset> #include <cctype> #include <cerrno> #include <clocale> #include <cmath> #include <complex> #include <cstdio> #incl…
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 代码: #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…
大致题意: 输入一个字典,字典格式为“英语à外语”的一一映射关系 然后输入若干个外语单词,输出他们的 英语翻译单词,如果字典中不存在这个单词,则输出“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 题意就是字典翻译.这个输入输出真心恶心,要不是看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&…
Numbers That Count Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 20396   Accepted: 6817 Description "Kronecker's Knumbers" is a little company that manufactures plastic digits for use in signs (theater marquees, gas station price…
[题意] 给一个字符串组成的矩阵,规模为n*m(n<=10000,m<=10),如果某两列中存在两行完全相同,则输出NO和两行行号和两列列号,否则输出YES [题解] 因为m很小,所以对每一行枚举其中两个字符串,检查之前行中对应的两列里是否重复即可.但是如何判重. 一开始想的把字符串做成pair然后用map映射为行号,但是TLE. 后来想到用hash判重,可能是因为哈希函数不够好,还是TLE... 总之这道题卡了三个小时,一直TLE. 枚举每一列,对枚举到的那一列从小到大排序,然后找到相邻两个…
题目链接:http://poj.org/problem?id=3974 Time Limit: 15000MS Memory Limit: 65536K Description Andy the smart computer science student was attending an algorithms class when the professor asked the students a simple question, "Can you propose an efficient…
Babelfish   Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 44545   Accepted: 18803 Description You have just moved from Waterloo to a big city. The people here speak an incomprehensible dialect of a foreign language. Fortunately, you ha…
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…
题意: 1 如果是严格升序的字母字符串,那么可以输出非0解码,否则不能译码输出0 2 字符串解码 遵循递增原则,其值为 到现在为止的所有按字母序小于该字符串的数量 + 1; #include <iostream> using namespace std; char ans[11]; int a[10]; int c[27][27]; long long f[10]; void generc(){//生成组合数 for(int i=1;i<27;i++)c[i][0]=c[i][i]=1;…
..] of string; i,n,l,r,mid:longint; s:string; procedure qsort(h,l:longint); var i,j:longint; temp,m:string; begin i:=h;j:=l;m:=x[(i+h)>>]; repeat while x[i]<m do inc(i); while x[j]>m do dec(j); if i<=j then begin temp:=x[i];x[i]:=x[j];x[j]:…
各种方式解这道题!! 利用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…
Andy the smart computer science student was attending an algorithms class when the professor asked the students a simple question, "Can you propose an efficient algorithm to find the length of the largest palindrome in a string?" A string is sai…