Babelfish
Time Limit: 3000MS   Memory Limit: 65536K
Total Submissions: 44537   Accepted: 18800

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 ogday
cat atcay
pig igpay
froot ootfray
loops oopslay atcay
ittenkay
oopslay

Sample Output

cat
eh
loops

Hint

Huge input and output,scanf and printf are recommended.
题意:翻译外文,根据输入的单词从字典里查找并输出对应的英文。
该题做法很多,难点在于输入,本菜鸟用了二分查找 AC代码
 #include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <iostream>
#include <sstream>
#include <algorithm>
using namespace std;
struct info
{
char e[];
char f[];
}d[];
bool compare(const info &a,const info &b)
{
return strcmp(a.f,b.f)<;
}
int main()
{
char a[];
int i,j,k=;
while(gets(a))
{
if(a[]=='\0')
break;
sscanf(a,"%s%s",d[k].e,d[k].f);
k++;
}
sort(d,d+k,compare);
while(gets(a))
{
int left,right,mid,n=;
left=;right=k-;
while(left<=right)
{
mid=(left+right)/;
if(strcmp(a,d[mid].f)==)
{
printf("%s\n",d[mid].e);
n=;
break;
}
else if(strcmp(a,d[mid].f)<)
right=mid-;
else
left=mid+;
}
if(n)
printf("eh\n");
}
return ;
}
												

2017ecjtu-summer training #2 POJ2503的更多相关文章

  1. hdu 4946 2014 Multi-University Training Contest 8

    Area of Mushroom Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) ...

  2. 2016 Multi-University Training Contests

    2016 Multi-University Training Contest 1 2016 Multi-University Training Contest 2 2016 Multi-Univers ...

  3. 2016 Multi-University Training Contest 2 D. Differencia

    Differencia Time Limit: 10000/10000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Tot ...

  4. 2016 Multi-University Training Contest 1 G. Rigid Frameworks

    Rigid Frameworks Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) ...

  5. ACM: Gym 101047K Training with Phuket's larvae - 思维题

     Gym 101047K Training with Phuket's larvae Time Limit:2000MS     Memory Limit:65536KB     64bit IO F ...

  6. The Solution of UESTC 2016 Summer Training #1 Div.2 Problem C

    Link http://acm.hust.edu.cn/vjudge/contest/121539#problem/C Description standard input/output After ...

  7. 2012 Multi-University Training Contest 9 / hdu4389

    2012 Multi-University Training Contest 9 / hdu4389 打巨表,实为数位dp 还不太懂 先这样放着.. 对于打表,当然我们不能直接打,这里有技巧.我们可以 ...

  8. 2014 Multi-University Training Contest 9#11

    2014 Multi-University Training Contest 9#11 Killing MonstersTime Limit: 2000/1000 MS (Java/Others)   ...

  9. 2014 Multi-University Training Contest 9#6

    2014 Multi-University Training Contest 9#6 Fast Matrix CalculationTime Limit: 2000/1000 MS (Java/Oth ...

随机推荐

  1. Scala 安装 Exception in thread "main" java.lang.VerifyError: Uninitialized object exists on backward branch 96

    windows下载安装完最新版本的Scala(2.12.4)后,终端如下错误 C:\Users\Administrator>scala -versionException in thread & ...

  2. Python的HTTP服务实例

    1.前言 今天需要实现一个Pyhton的http服务,与Web的JS进行交换. 2.实例代码 支持HEAD.GET.POST方法,将参数转换为JSON格式,返回结果以JSON字符串返回. import ...

  3. 637. Average of Levels in Binary Tree

    Given a non-empty binary tree, return the average value of the nodes on each level in the form of an ...

  4. 模板引擎(smarty)知识点总结II

    今天咱们继续来学习smarty!!! 知识点1:对于三种变量 常量的引用 有哪三种变量?a.assign赋值 b.系统保留变量(包括:$smarty.get,$smarty.post,$smarty. ...

  5. JAVA NIO学习二:通道(Channel)与缓冲区(Buffer)

    今天是2018年的第三天,真是时光飞逝,2017年的学习计划还没有学习完成,因此继续开始研究学习,那么上一节我们了解了NIO,那么这一节我们进一步来学习NIO相关的知识.那就是通道和缓冲区.Java ...

  6. shell脚本异步日志分析-接口耗时、可用率

    背景:现有日志接入日志报表大盘,为了避免作业高峰期间(双十一),系统也要观测系统整体情况,因此提出了观测近五分钟,接口成功率以及耗时等工具(默认统计最近五分钟,并进行结果汇总统计) 使用说明 前提:p ...

  7. mvc4.5更改为mvc4.0方法总结

    一:使用MVC4.5创建的项目结果IIS服务器不支持(windows server2008 支持.net4.0),整了半天终于有点眉目了,方法如下: 1.先将项目所在的文件夹找到,去掉文件夹及其文件的 ...

  8. python 模块:csv

    转自:http://www.cnblogs.com/sislcb/archive/2008/12/15/1355481.html (感谢整理) 举几个例子来介绍一下,Python 的 CSV模块的使用 ...

  9. python爬虫——写出最简单的网页爬虫

    在我们日常上网浏览网页的时候,经常会看到一些好看的图片,我们就希望把这些图片保存下载,或者用户用来做桌面壁纸,或者用来做设计的素材.我们可以通过python 来实现这样一个简单的爬虫功能,把我们想要的 ...

  10. [Micropython]发光二极管制作炫彩跑马灯

       先甩锅 做完后才发现最后一个灯坏了,就坏了一个灯也不好意思去找淘宝店家,大家视频凑合着看把.不过并不影响实验效果.因为这个发光二极管白天不是很明显 晚上炫彩效果就能出来了.本次实验用的是8个灯珠 ...