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. hibernate 3.6.10 maven pom.xml

    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/20 ...

  2. Linux发行版 CentOS6.5下删除分区操作

    本文地址http://comexchan.cnblogs.com/,作者Comex Chan,尊重知识产权,转载请注明出处,谢谢!   有时候,发现分区分错了.需要删除分区,只需按照分区的步骤逆向操作 ...

  3. Dubbo(二) 认识Zookeeper

    前言 在昨天,我们给大家基本介绍了Dubbo,文中反复提到了Zookeeper,那么它到底是什么呢,这篇文章我们将从Dubbo层面去了解Zookeeper,不做全面讲解,毕竟这是Dubbo教程啊~ Z ...

  4. 1.php开发环境安装

    1.安装环境 在链接https://sourceforge.net/projects/xampp/files/下载集成开发环境,此集成了web服务器.php开发.mysql数据库.傻瓜式安装step ...

  5. springBoot系列教程05:fastjson的集成、配置及使用

    springBoot自带的json用着不太习惯,已习惯了fastJSON,下面介绍下fastjson的配置 1. pom引入 <dependency> <groupId>com ...

  6. Centos7上安装使用locate

    centos7上默认没有locate命令,需先安装locate yum install mlocate 注意是mlocate,如果是yum install locate系统会提示没有安装包 安装完成后 ...

  7. mayavi安装

    Mayavi是python的一个包,提供方便的可视化方案.目前(20150809)Mayavi还没有py3的支持,以下安装环境在python 2.7.10下进行 安装Mayavi: 1. 通过pip ...

  8. partition length exceeds the loop-partition-table-imposed maximum of 4294967295

    问题: 当大于2T的磁盘,在用parted操作的时候,会出现这样的报错,原因是因为现在的分区表是mbr,需要修改为gpt.mbr最大支持2T的空间. 解决方法: 搞清楚问题,解决方法也很简单:mkla ...

  9. Java数组的创建和初始化

    我们说到数组,可能有的人就会比较害怕了,其实,数组只是把对象序列(很多个对象)或者基本类型序列(很多个基本类型)放在一起而已.数组是通过方括号下标操作符[]来定义和使用的.如果要定义,创建一个数组,只 ...

  10. 【python3之变量,输入输出,判断,循环】

    一.python的基础语法和规则 1.变量 ①.变量的命名规则 语法: (下划线或字母)+(任意数目的字母.数字或下划线) 变量名必须以下划线或字母开头,而后面接任意数目的字母.数字或下划线.下划线分 ...