POJ 2503 Babelfish(STL-map)
来源:互联网 发布:彗星dns优化 编辑:程序博客网 时间:2024/06/05 18:11
Babelfish
Time Limit: 3000MS Memory Limit: 65536KTotal Submissions: 40446 Accepted: 17225
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 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.
题意:就是上面一个字典,一个字符串对应一个字符串,后面给出一堆单词,问在字典中对应的单词是什么,并输出;没有就输出 eh
题解:map搞搞,不过G++会TLE,C++能过 (;′⌒`)
代码如下:
#include<cstdio>#include<iostream>#include<cstring>#include<string>#include<algorithm>#include<map>using namespace std;#define maxn 100010char str[20],s[20],word[20];int main(){map<string,bool>appear;map<string,string>translate;int i;while(1){char t;t=getchar();if(t=='\n')break;else{str[0]=t;i=1;while(1){t=getchar();if(t==' '){str[i]='\0';break;}str[i++]=t;}}scanf("%s",s);getchar();appear[s]=true;translate[s]=str;} while(scanf("%s",word)!=EOF){if(appear[word])cout<<translate[word]<<endl;elseprintf("eh\n");}return 0;}
0 0
- POJ 2503 Babelfish(STL-map)
- poj 2503 Babelfish(STL map写法)
- POJ 2503 Babelfish STL-map容器
- POJ 2503-Babelfish(STL-map)
- POJ 2503 Babelfish ,map
- Babelfish - POJ 2503 map
- POJ 2503-Babelfish(map)
- poj 2503 Babelfish (map)
- poj 2503 Babelfish (map)
- POJ 2503 - Babelfish(STL)
- 【POJ】2503 - Babelfish(STL)
- Poj 2503 Babelfish(Map操作)
- poj 2503 Babelfish (map / 二分)
- POJ 2503 Babelfish map做法
- POJ 2503 Babelfish(map)
- POJ 2503 Babelfish [map & string]
- 10282 - Babelfish(stl map)
- poj2503 Babelfish(STL-map)
- CodeIgniter框架源码笔记(9)——日志记录类Log.php
- 策略模式
- nyoj 17 单调递增最长子序列
- Android textview实现局部点击
- Js基础学习之-- 利用GET方法实现ajax请求
- POJ 2503 Babelfish(STL-map)
- 学习Android源码应该避免的
- 已知两种遍历序列求原始二叉树
- 关于参加学科竞赛的心得感想
- 动画
- River Hopscotch poj 3258
- 浅析Windows安全认证机制及利用
- 学习过程中整理的有关centos的一些安装笔记
- JS自学|常用互动方法