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代码: ...
随机推荐
- 解决python3在sublim Text3中中文乱码的问题
在Tool >> BulidingSystem 中 新建 python3 写入如下代码 { "cmd": ["C:/python3/python.exe&q ...
- C++进阶 STL(1) 第一天 [容器,算法,迭代器] string容器 vector容器 deque容器
课程大纲 02实现基本原理 容器,算法,迭代器 教室:容器 人:元素 教室对于楼:容器 序列式容器: 容器元素在容器中的位置是由进入容器的时间和地点来决定 序列式容器 关联式容器: 教室中 按年龄排座 ...
- vue 面试题 2019
vue核心知识点 1.对于Vue是一套渐进式框架的理解 渐进式代表的含义是:主张最少. Vue可能有些方面是不如React,不如Angular,但它是渐进的,没有强主张,你可以在原有大系统的上面,把一 ...
- 终极对决!Dubbo 和 Spring Cloud 微服务架构到底孰优孰劣
标签: 微服务dubbospring架构 前言 微服务架构是互联网很热门的话题,是互联网技术发展的必然结果.它提倡将单一应用程序划分成一组小的服务,服务之间互相协调.互相配合,为用户提供最终价值.虽然 ...
- 2019-03-25 SQL SET ANSI_NULLS /SET QUOTED_IDENTIFIER /SET NOCOUNT ON
use database go /**当 SET ANSI_NULLS 为 ON 时,即使 column_name 中包含空值,使用 WHERE column_name = NULL 的 SELECT ...
- 《代码敲不队》第八次团队作业:Alpha冲刺 第五天
项目 内容 这个作业属于哪个课程 任课教师博客主页链接 这个作业的要求在哪里 作业链接地址 团队名称 代码敲不队 作业学习目标 掌握软件编码实现的工程要求. 团队项目github仓库地址链接 GitH ...
- Profile 动态切换环境
一.多 Profile 文件我们在主配置文件编写的时候,文件名可以是 application-{profile}.properties/yml默认使用 application.properties 的 ...
- [SQL]存储过程建表
create PROC [dbo].CreateUserTable ( @name NVARCHAR(60) ) AS DECLARE @a NVARCHAR(max) SET @a='create ...
- GA求解TSP
遗传算法中包含了如下5个基本要素: (1)对参数进行编码: (2)设定初始种群大小: (3)适应度函数的设计: (4)遗传操作设计: (5)控制参数设定(包括种群大小.最大进化代数.交叉率.变异率等) ...
- Keyboard的显示与隐藏
一个控制键盘显示与隐藏的工具类分享给大家 public class KeyBoardTool { /** * 假设输入法在窗体上已经显示.则隐藏.反之则显示 * @param context */ p ...