Babelfish
来源:互联网 发布:java中object类的方法 编辑:程序博客网 时间:2024/05/29 12:54
B - Babelfish
Time Limit:3000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64uDescription
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 entries, followed by a blank line, followed by a message of up to 100,000 words. Each dictionary entry is a line containing an English word, followed by a space and a foreign language word. No foreign word appears more than once in the dictionary. The message is a sequence of words in the foreign language, one word on each line. Each word in the input is a sequence of at most 10 lowercase letters.
Output
Output is the message translated to English, one word per line. Foreign words not in the dictionary should be translated as "eh".
Sample Input
dog ogdaycat atcaypig igpayfroot ootfrayloops oopslayatcayittenkayoopslay
Sample Output
catehloops
Hint
Huge input and output,scanf and printf are recommended.
AC代码:
#include<iostream>#include<algorithm>#include<cstring>#include<string>#include<cstdio>using namespace std;struct S{string str;S* kid[26];S(){str="";for(int i=0;i<26;++i){kid[i]=NULL;}}}*root;void insert(string st,string str){S* t=root;int d;for(int i=0;str[i];++i){d=str[i]-'a';if(t->kid[d]==NULL){t->kid[d] = new S;}t=t->kid[d];if(!str[i+1])t->str+=st;}}string find(string str){S* t = root;int d;for(int i=0;str[i];++i){d = str[i]-'a';if(t->kid[d]==NULL){return "eh";}t = t->kid[d];}return t->str;}int main(){char s[100];string str,st;root = new S;while(gets(s)&&s[0]){int c=0,f=1;for(int i=0;s[i];++i){if(s[i]==' ')f=0,i++;if(f){str+=s[i];}elsest+=s[i];}insert(str,st);st="";str="";}while(cin >> str){cout << find(str) << endl;}return 0;}
0 0
- Babelfish
- Babelfish
- Babelfish
- Babelfish
- Babelfish
- Babelfish
- Babelfish
- Babelfish
- Babelfish
- Babelfish
- Babelfish
- R - Babelfish
- 10282 - Babelfish(***)
- 【STL】Babelfish
- POJ2503 Babelfish
- Babelfish poj2503
- 10282 - Babelfish
- POJ2503 Babelfish
- 基于highcharts封装的一个简单易用的报表统计
- 先序遍历创建二叉树,对二叉树统计叶子节点个数和统计深度(创建二叉树时#代表空树,序列不能有误)c语言
- 转Array.prototype.slice.call(arguments)
- Linux bridge-utils tunctl 使用
- ok6410 LED/GPIO 控制 C#程序
- Babelfish
- Phone List(trie树)
- 枚举 hdu1172 猜数字
- Unity3d中的Awake()、OnEnable()、Start()等默认函数的执行顺序和生命周期
- arm linux kernel 从入口到start_kernel 的代码分析
- hdu5247 找连续数 离线排序
- 内存管理之计数器的基本操作
- shopex网店加速,解决shopex网店 CPU% 高占用问题
- Vmware qemu-kvm 虚拟化测试