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代码: ...
随机推荐
- Jquery中拿到相同的对应的所有的标签
在Jquery中相同的ID号不能用$()获得,即使是$().each()也不能获得所有的ID相同的元素,只能获得第一个匹配的元素. 比如: 以上4个div,如果用$("#jevoly&quo ...
- centos7常见的操作
centos7的网络IP地址配置文件在 /etc/sysconfig/network-scripts 文件夹下, 查看当前网卡名称 ip ad li ens33网卡对应的配置文件为ifcfg-ens ...
- A*寻路算法详解
以我个人的理解: A*寻路算法是一种启发式算法,算法的核心是三个变量f,g,h的计算.g表示 从起点 沿正在搜索的路径 到 当前点的距离,h表示从当前点到终点的距离,而f=g+h,所以f越小,则经过当 ...
- 【JavaScript框架封装】公共框架的封装
/* * @Author: 我爱科技论坛 * @Time: 20180706 * @Desc: 实现一个类似于JQuery功能的框架 // 公共框架 // 种子模块:命名空间.对象扩展.数组化.类型的 ...
- 洛谷P1914 小书童——密码
题目背景 某蒟蒻迷上了"小书童",有一天登陆时忘记密码了(他没绑定邮箱or手机),于是便把问题抛给了神犇你. 题目描述 蒟蒻虽然忘记密码,但他还记得密码是由一串字母组成.且密码是由 ...
- 训练1-N
给出N个整数,对着N个整数进行排序 Input 第1行:整数的数量N(1 <= N <= 50000)第2 - N + 1行:待排序的整数(-10^9 <= Ai <= 10^ ...
- android Build系统
http://www.ibm.com/developerworks/cn/opensource/os-cn-android-build/ android Build系统 超链接
- 一个简单的 PC端与移动端的适配(通过UA)
只需在header引用个js文件, 原理就是判断UA里面的标识. 加下面代码添加到js文件,在头文件引用即可 var Pc_url = 'http://www.baidu.com'; //PC端网址 ...
- 启动 Appium 自带模拟器
1.先在sclipse中新建并打开一个设备 2.启动appium 3.安装apk 打开cmd 并在sdk安装目录的tools文件夹下输入安装命令adb install xxx.apk(在这之前需要把 ...
- SimpleDateFormat 格式化 解析
package chengbaoDemo; import java.text.DateFormat; import java.text.ParseException; import java.text ...