Kattis - Babelfish
Babelfish
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 100000100000 dictionary entries, followed by a blank line, followed by a message of up to 100000100000 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 non-empty sequence of at most 1010lowercase 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 1 | Sample Output 1 |
---|---|
dog ogday |
cat |
题意
前面那部分是字典里的,后面就查找给出的字符串有没有属于前面的字典里,有的话就输出那个单词
思路
用map存就行了
代码
#include<bits/stdc++.h>
using namespace std;
map<string,string> m;
int main(){
string line,a,b;
while(getline(cin,line)&&line!=""){
stringstream s(line);//格式转换
s>>a;
s>>b;
m[b]=a;
}
while(cin>>b){
a=m[b];
cout<<(a==""?"eh":a)<<endl;
}
}
Kattis - Babelfish的更多相关文章
- Babelfish(二分查找,字符串的处理略有难度,用sscanf输入)
Babelfish Time Limit: 3000MS Memory Limit: 65536K Total Submissions: 28581 Accepted: 12326 题目链接: ...
- poj 2503:Babelfish(字典树,经典题,字典翻译)
Babelfish Time Limit: 3000MS Memory Limit: 65536K Total Submissions: 30816 Accepted: 13283 Descr ...
- POJ 2503 Babelfish
Babelfish Time Limit: 3000MS Memory Limit: 65536K Total Submissions: 28766 Accepted: 12407 Descripti ...
- Babelfish 分类: 哈希 2015-08-04 09:25 2人阅读 评论(0) 收藏
Babelfish Time Limit: 3000MS Memory Limit: 65536K Total Submissions: 36398 Accepted: 15554 Descripti ...
- Poj 2503 / OpenJudge 2503 Babelfish
1.Link: http://poj.org/problem?id=2503 http://bailian.openjudge.cn/practice/2503/ 2.Content: Babelfi ...
- POJ2503——Babelfish(map映射+string字符串)
Babelfish DescriptionYou have just moved from Waterloo to a big city. The people here speak an incom ...
- Babelfish(二分)
Babelfish Time Limit: 3000MS Memory Limit: 65536K Total Submissions: 37238 Accepted: 15879 Descr ...
- http://begin.lydsy.com/JudgeOnline/problem.php?id=2770(PKU2503 Babelfish)
2770: PKU2503 Babelfish Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 2 Solved: 2[Submit][Status][ ...
- It's a Mod, Mod, Mod, Mod World Kattis - itsamodmodmodmodworld (等差数列求和取模)
题目链接: D - It's a Mod, Mod, Mod, Mod World Kattis - itsamodmodmodmodworld 具体的每个参数的代表什么直接看题面就好了. AC代码: ...
随机推荐
- 解决AttributeError: 'module' object has no attribute 'main' 安装第三方包报错
1.找到pycharm 目录下的 \helper\packaging_tool.py 文件 2.用新版pycharm 的packaging_tool.py 替换 旧版 同名文件 文件代码如下: imp ...
- [luogu 1270] “访问”美术馆 (树形dp)
传送门 Description 经过数月的精心准备,Peer Brelstet,一个出了名的盗画者,准备开始他的下一个行动.艺术馆的结构,每条走廊要么分叉为两条走廊,要么通向一个展览室.Peer知道每 ...
- Linux 文件压缩
压缩工具 compress/uncompress:对应 .Z 结尾的压缩格式文件 压缩格式:gz.bz2.xz.zip.Z gzip 压缩文件并删除源文件(生成.gz的文件) gunzip 解 ...
- Windows常用软件
目录 Uninstall Tool FACapture Unlocker Uninstall Tool Uninstall Tool 这是一款可以彻底删除应用的软件,能连通注册表内容一起删除. FAC ...
- 利用Tensorflow训练自定义数据
很多正在入门或刚入门TensorFlow机器学习的同学希望能够通过自己指定图片源对模型进行训练,然后识别和分类自己指定的图片.但是,在TensorFlow官方入门教程中,并无明确给出如何把自定义数据输 ...
- indy10中idtcpclient的使用问题[和大华电子称数据交换]
在实际事务应用中,多次打开server进行大写.其中遇到一些问题,由于时间关系,没有好好整理,虽然问题解决了, 但原因和其他方法没有去进一步测试. 1.每个单元用本地TidTCPClient变量连接s ...
- spring data JPA使用quartz定时器的具体实现
第一步.在pom.xml中的配置 <!--quartz--> <dependency> <groupId>org.quartz-scheduler</grou ...
- java陷阱之spring事物未提交和回滚导致不可预知问题
案发现场 //防止全局配置了 所以这里定义sprnig 不托管事物 @Transactional(propagation = Propagation.NOT_SUPPORTED) public boo ...
- ibatis的批处理
(1)spring模式:尽管spring已经配置了事务,但以下代码中还是要设置事务,不然batch不会起作用;另外这里虽然设了一下事务处理,但对全局事务并不会造成影响;注:不启用事务将建立多次连接,这 ...
- Android网络编程(十)Retrofit2后篇[注解]
G相关文章 Android网络编程(一)HTTP协议原理 Android网络编程(二)HttpClient与HttpURLConnection Android网络编程(三)Volley用法全解析 An ...