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. bzoj 1179: [Apio2009]Atm

    Description Input 第 一行包含两个整数N.M.N表示路口的个数,M表示道路条数.接下来M行,每行两个整数,这两个整数都在1到N之间,第i+1行的两个整数表示第i条道路 的起点和终点的 ...

  2. javascript01

    手敲代码01 <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <ti ...

  3. C#生成缩略图 (通用模式)

    用数据库保存图片的路径和文件名称,把文件保存在文件夹中.//保存在数据库中的文件路径ArrayList arrFilePath=new ArrayList();arrFilePath=myCommon ...

  4. String源码图

    String StringBuffer StringBuilder 均为对字符数组的操作. 实现了不同的接口,导致不同的覆写. 实现了同样的接口,适应不同的场景.

  5. Golang 网络爬虫框架gocolly/colly 一

    Golang 网络爬虫框架gocolly/colly 一 gocolly是用go实现的网络爬虫框架,目前在github上具有3400+星,名列go版爬虫程序榜首.gocolly快速优雅,在单核上每秒可 ...

  6. Struts2-整理笔记(一)介绍、搭建、流程、详解struts.xml

    Struts2是一种前端的技术框架 替代Servlet来处理请求   Struts2优势 自动封装参数 参数校验 结果的处理(转发|重定向) 国际化 显示等待页面 表单的防止重复提交   搭建框架:导 ...

  7. 【分治】peak find

    分治算法 算法设计中一种常用的优化方法就是分治的思想,它的解决思路就是将原始的问题划分为性质一样,但是规模减小的子问题,然后通过子问题的解和合并子问题的解得到最终的解,就是分治的思想: 比较常见的分治 ...

  8. C# 给枚举类型增加一个描述特性

    前言 相信很多人对枚举并不陌生,枚举可以很方便和直观的管理一组特定值.如果我们在页面上直接输出我们希望匹配的汉语意思或则其他满足我们需求的语句就更好了,当然,通常小伙伴们都会再页面上if(enum== ...

  9. 关于HTTP协议头域详解

    HTTP1.1 请求头:消息头  Accept:text/html,image/*  告诉服务器,客户机支持的数据类型 Accept-Charset:ISO-8859-1  告诉服务器,客户机采用的编 ...

  10. 三栏布局之 css3 calc和 flex

    圣杯布局的实现,有很多种. 大致都是借助 padding, margin, float之类的,当然这是传统的实现方式.更多的参考方式圣杯布局小结. 这里说的是用css3 cal 和flex来实现,因为 ...