UVA 10282 (13.08.18)
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)的更多相关文章
- UVA 10194 (13.08.05)
:W Problem A: Football (aka Soccer) The Problem Football the most popular sport in the world (ameri ...
- UVA 253 (13.08.06)
Cube painting We have a machine for painting cubes. It is supplied withthree different colors: blu ...
- 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 ...
- UVA 10499 (13.08.06)
Problem H The Land of Justice Input: standard input Output: standard output Time Limit: 4 seconds In ...
- UVA 10025 (13.08.06)
The ? 1 ? 2 ? ... ? n = k problem Theproblem Given the following formula, one can set operators '+ ...
- UVA 465 (13.08.02)
Overflow Write a program that reads an expression consisting of twonon-negative integer and an ope ...
- UVA 10494 (13.08.02)
点此连接到UVA10494 思路: 采取一种, 边取余边取整的方法, 让这题变的简单许多~ AC代码: #include<stdio.h> #include<string.h> ...
- UVA 424 (13.08.02)
Integer Inquiry One of the first users of BIT's new supercomputer was Chip Diller. Heextended his ...
- UVA 10106 (13.08.02)
Product The Problem The problem is to multiply two integers X, Y. (0<=X,Y<10250) The Input T ...
随机推荐
- .NET 中使用 HttpWebResponse 时 Cookie 的读取
今天把一个网站登录配置到以前写的蜘蛛程序中,发现不能成功登录.检查后才发现,那个网站在登录成功后,输出了一个特殊路径的 Cookie,由于是使用 HttpWebRequest.Cookies 来获取的 ...
- [转]轻量级 Java Web 框架架构设计
工作闲暇之余,我想设计并开发一款轻量级 Java Web 框架,看看能否取代目前最为流行的而又越来越重的 Spring.Hibernate 等框架.请原谅在下的大胆行为与不自量力,本人不是为了重造轮子 ...
- PHP session 跨子域问题总结
Session主要分两部分: 一个是Session数据,该数据默认情况下是存放在服务器的tmp文件下的,是以文件形式存在 另一个是标志着Session数据的Session Id,Session ID, ...
- 整合 新浪 腾讯 人人 qq空间 分享地址
function snsShare(snsId, title, content, image, url) { var snsUrl; // 新浪 腾讯 要申请appkey switch (snsId) ...
- magic Ajax使用以及注意事项
以下是引用片段:一.概述 现在Ajax技术正如火如荼的在Internet上发展着.而面对我们之前开发的ASP.NET1.1的Web项目,类似于下拉框等联动也需要啪啪啪的不断刷新,的确影响到了用户 ...
- System.Speech.Synthesis 添加暂停、继续功能
为了方便调用暂停.继续的方法.要将speech的功能写成一个类.直接附上代码: using System; using System.Collections.Generic; using System ...
- Android-------设置TextView同时显示图片和文本,并控制图片大小
//获取资源图片 Drawable leftDrawable = getResources().getDrawable(R.drawable.comment_parise); //设置 ...
- Git应用于Android项目的入门知识:我的理解
Git应用于Android项目的基本知识. 常常将git,repo和gerrit三种工具配合起来使用,使Android开发中的部分工作自动化.并适应敏捷项目管理的需要. repo是Go ...
- hdu1466 计算直线的交点数
题意: 平面上有n条直线,且无三线共点,问这些直线能有多少种不同交点数. 比如,如果n=2,则可能的交点数量为0(平行)或者1(不平行). 分析: DP 设状态:f[i][j]表示i条直线能否产生j个 ...
- nginx+keepalived+tomcat之具体配置档
前沿知识点: nginx负责负载均衡(反向代理) msm(memcached session manager)负责缓存会话信息,从而实现会话保持 所需包: nginx和memcached采用最新稳定版 ...