Babelfish
Time Limit: 1000MS Memory limit: 65536K
题目描述
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 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 is the message translated to English, one word per line. Foreign words not in the dictionary should be translated as "eh".
示例输入
dog ogday
cat atcay
pig igpay
froot ootfray
loops oopslay
atcay
ittenkay
oopslay示例输出
cat
eh
loops
这个题觉得不难,本意是字典树,自己不会,各种水,用数组也可以做,但是一定会超时
用map水了一下,感觉空行结束太没有爱了害我纠结了半天
#include<cstdio>
#include<iostream>
#include<map>
using namespace std;
int main()
{
map<string,string>mapp;//map,不解释
char ch,s[],p[];
while(scanf("%c",&ch))
{
if(ch=='\n')break;//解决那个烦人的空行结束
s[]=ch;
scanf("%s",s+);
scanf("%s",p);
getchar();
mapp.insert(pair<string,string>(p,s));//插入语句
}
map<string,string>::iterator iter;//声明迭代器,别问我什么用,我也不知道
while(~scanf("%s",s))
{
iter=mapp.find(s);//查找啊
if(iter!=mapp.end())//这个说明找到了
printf("%s\n",iter->second.c_str());//打印出来,别忘了后面的.c_str();
else
printf("eh\n");
}
return ;
}
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][ ...
- Babelfish 基本试用
测试使用docker 部署 docker-compose文件 注意网络模型选择的host,同时配置了opentracing 服务 version: "3" services: b ...
- Babelfish 开源通用代码解析服务
Babelfish 是一个开源的代码解析服务 参考架构 支持的语言 bash go java javascript php ruby c++ typescript 功能 我们可以使用此工具,进行大规模 ...
随机推荐
- Qt之遍历文件夹(经典详解)
关于Qt操作文件夹.文件的知识用途较多,比如遍历下一层乃至所有子孙文件.文件夹,获取它们的一些信息(大小.类型.最后更改时间等).当然,也可以进行级联删除. 首先看简单的: 一.Qt遍历文件夹 ...
- SQL Server手工插入标识列
如果我们在标识列中插入值,例如: insert member(id,username) values(10,'admin') 则在查询分析器里面会返回错误信息: 引用内容 服务器: 消息 544,级别 ...
- hadoop资料汇总(网上)
http://blog.csdn.net/fansy1990/article/list/3 全部是hadoop的,挺好. http://stackoverflow.com/ ...
- block代码块介绍
关于block的简单介绍 什么是block? Block是C语言的一个语法特性,同时也是C语言的运行时特性,它很像C中的函数指针,因为你可以像使用函数指针一样的去使用block对象:它也很像C++中的 ...
- java 反射调用支付SDK
在android开发中会遇到各种SDK的接入,很是麻烦.最初在想能不能把所有的SDK都 融合到一个当中,发现有点异想天开.但是也可以解决SDK资源不小心没有引入,导致程序调用接口崩溃问题.经过查资料, ...
- oracle 里面定时执行任务,比如存储过程内容等。
DECLARE job_no_ NUMBER; BEGIN DBMS_JOB.SUBMIT(job_no_, 'proc_qszx_dw_sc(' ...
- 菜鸟学开店—自带U盘的打印机
本文旨在提供最简单.便宜.有效的解决方案,解决普通用户最困扰的问题.今天提供普通用户一个低价的小票打印机驱动安装解决方案 相信很多用户都碰到过这种情况,电脑的重装了系统,打印机的驱动没有备份,要用打印 ...
- mysql workbench 建表时 PK,NN,UQ,BIN,UN,ZF,AI解释
mysql workbench 建表时 - PK: primary key (column is part of a pk) 主键 - NN: not null (column is nullable ...
- 移动触摸事件(touchstart、touchmove和touchend)
touchstart事件:当手指触摸屏幕时候触发,即使已经有一个手指放在屏幕上也会触发. touchmove事件:当手指在屏幕上滑动的时候连续地触发.在这个事件发生期间,调用preventDefaul ...
- 1.swt/rap学习源码网址
1.rap使用JS/ RAP加载JS http://download.eclipse.org/rt/rap/doc/2.3/guide/reference/jsdoc/symbols/rap.html ...