Problem C: Babelfish

You have just moved from Waterloo to a big city. The people here speakan incomprehensible dialect of a foreign language. Fortunately, you havea dictionary to help you understand them.

Input consists of up to 100,000 dictionary entries, followed by a blankline, followed by a message of up to 100,000 words. Each dictionaryentry is a line containing an English word, followed by a space and aforeign language word. No foreign word appears more than once in thedictionary. 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 10lowercase letters.Output is the message translated to English, one word per line. Foreignwords not in the dictionary should be translated as "eh".

Sample Input

dog ogday
cat atcay
pig igpay
froot ootfray
loops oopslay atcay
ittenkay
oopslay

Output for Sample Input

cat
eh
loops

题意: 这么短的题目还用我解释?

解法: 按出题者意思是要用哈希算法, 但是可用STL中的map

AC代码:

#include<stdio.h>
#include<iostream>
#include<string>
#include<map> using namespace std; char str1[30];
char str2[30];
char str[50]; map<string, string> Map; int main() {
Map.clear(); while(gets(str) != NULL) {
if(str[0] == '\0')
break;
sscanf(str, "%s %s", str1, str2);
Map[str2] = str1;
} while(scanf("%s", str) != EOF) {
if(Map.find(str) != Map.end())
cout<< Map[str] <<endl;
else
printf("eh\n");
}
return 0;
}

UVA 10282 (13.08.18)的更多相关文章

  1. UVA 10194 (13.08.05)

    :W Problem A: Football (aka Soccer)  The Problem Football the most popular sport in the world (ameri ...

  2. UVA 253 (13.08.06)

     Cube painting  We have a machine for painting cubes. It is supplied withthree different colors: blu ...

  3. UVA 573 (13.08.06)

     The Snail  A snail is at the bottom of a 6-foot well and wants to climb to the top.The snail can cl ...

  4. UVA 10499 (13.08.06)

    Problem H The Land of Justice Input: standard input Output: standard output Time Limit: 4 seconds In ...

  5. UVA 10025 (13.08.06)

     The ? 1 ? 2 ? ... ? n = k problem  Theproblem Given the following formula, one can set operators '+ ...

  6. UVA 465 (13.08.02)

     Overflow  Write a program that reads an expression consisting of twonon-negative integer and an ope ...

  7. UVA 10494 (13.08.02)

    点此连接到UVA10494 思路: 采取一种, 边取余边取整的方法, 让这题变的简单许多~ AC代码: #include<stdio.h> #include<string.h> ...

  8. UVA 424 (13.08.02)

     Integer Inquiry  One of the first users of BIT's new supercomputer was Chip Diller. Heextended his ...

  9. UVA 10106 (13.08.02)

     Product  The Problem The problem is to multiply two integers X, Y. (0<=X,Y<10250) The Input T ...

随机推荐

  1. CSDN 正整数异或值问题

    题目详情: http://student.csdn.net/mcs/programming_challenges?page=4 给你n个正整数,请你计算出有多少对数的异或值小于等于k. 输入描写叙述: ...

  2. IDataParameter调用存储过程

    public string  GenerateExamePaper(string paperType, string driverID, string MacAddr)         {       ...

  3. ACM-简单题之Ignatius and the Princess II——hdu1027

    转载请注明出处:http://blog.csdn.net/lttree Ignatius and the Princess II Time Limit: 2000/1000 MS (Java/Othe ...

  4. Linux下Samba的配置

    前言: 为了实现windows 和 Linux以及其它操作系统之间的资源共享,软件商推出nfs 和samba两种解决方案.因为市场上缺乏象pc-nfs那样的client工具,使得Linux和windo ...

  5. Android 打造自己的个性化应用(五):仿墨迹天气实现续--> 使用Ant实现zip/tar的压缩与解压

    上一篇中提到对于Zip包的解压和压缩需要借助Ant 实现,我经过参考了其他的资料,整理后并加上了一些自己的看法: 这里就具体地讲下如何使用Ant进行解压缩及其原因: java中实际是提供了对  zip ...

  6. GridView控件中插入自定义删除按钮并弹出确认框

    GridView控件中插入自定义删除按钮,要实现这个功能其实有多种方法,这里先记下我使用的方法,以后再添加其他方法. 一.实现步骤 1.在GridView中添加模板列(TemplateField). ...

  7. SqlBulkCopy类进行大数据(一万条以上)插入测试

    好多天没写博客了,刚刚毕业一个多月! 关于上一篇博客中提到的,在进行批量数据插入数据库的时候可以通过给存储过程传递一个类型为Table的参数进行相关操作,在这个过程中本人没有进行效率的测试.后来查找发 ...

  8. tabbar加小红点

    原文   http://blog.csdn.net/u013531246/article/details/44460115 #import <UIKit/UIKit.h> @interfa ...

  9. (原)安装windows8.1和ubuntu16双系统及相互访问磁盘

    转载请注明出处: http://www.cnblogs.com/darkknightzh/p/5638232.html 参考网址: http://jingyan.baidu.com/article/f ...

  10. 初学linux命令

    linux系统的精髓在于它的命令行 早就听说要学习linux系统,就要学习它的命令行(Command Line Interface).说来惭愧,已经使用了linuxmint快两个月了,虽然能够使用一些 ...