zoj 1109 Language of FatMouse(map)
Language of FatMouse
Time Limit: 10 Seconds Memory Limit: 32768 KB
We all know that FatMouse doesn't speak English. But now he has to be prepared since our nation will join WTO soon. Thanks to Turing we have computers to help him.
Input Specification
Input consists of up to 100,005 dictionary entries, followed by a blank line, followed by a message of up to 100,005 words. Each dictionary entry is a line containing an English word, followed by a space and a FatMouse word. No FatMouse word appears more than once in the dictionary. The message is a sequence of words in the language of FatMouse, one word on each line. Each word in the input is a sequence of at most 10 lowercase letters.
Output Specification
Output is the message translated to English, one word per line. FatMouse 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
Output for Sample Input
cat
eh
loops
思路:主要应用映照容器map,其次是数据的处理,该如何判断对应完了,而该输出了,这里要根据那个空行判断。所以应该一行一行输入。
#pragma warning(disable:4786)
#include <iostream>
#include <map>
#include <string>
#include <cstdio>
#include <cstring>
using namespace std;
int main(){
map<string, string> mp;
string s;
char ss[], s1[], s2[];
while(gets(ss)){
s = ss;
if(s == ""){
break;
} else {
sscanf(s.c_str(), "%s %s", s1, s2);//固定输入源字符串
mp[s2] = s1;
}
}
map<string, string>::iterator it;
while(gets(ss)){
s = ss;
it = mp.find(s);
if(it != mp.end())
printf("%s\n", mp[s].c_str());
else
printf("eh\n");
}
return ;
}
zoj 1109 Language of FatMouse(map)的更多相关文章
- zoj 1109 Language of FatMouse(map映照容器的典型应用)
题目连接: acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=1109 题目描述: We all know that FatMouse doe ...
- zoj 1109 Language of FatMouse(字典树)
Language of FatMouse Time Limit: 10 Seconds Memory Limit: 32768 KB We all know that FatMouse do ...
- ZOJ 1109 Language of FatMouse 【Trie树】
<题目链接> 题目大意: 刚开始每行输入两个单词,第二个单词存入单词库,并且每行第二个单词映射着对应的第一个单词.然后每行输入一个单词,如果单词库中有相同的单词,则输出它对应的那个单词,否 ...
- zoj 1109 Language of FatMouse 解题报告
题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=109 题目意思:给出一个mouse-english词典,问对于输入的m ...
- ZOJ 1109 Language of FatMouse
较简单字典树,每输入一对字符串,前一个放在字典(数组)中,后一个插入字典树中,并将其最终的flag赋为前一个在数组中的下标,再就好找了.输入的处理方法要注意一下. 代码: #include <i ...
- zoj 1109 zoj 1109 Language of FatMouse(字典树)
好开心,手动自己按照字典树的思想用c写了一个优化后的trie字典树,就是用链表来代替26个大小的字符数组.完全按照自己按照自己的想法打的,没有参考如何被人的代码.调试了一天,居然最后错在一个小问题上, ...
- ZOJ Problem Set - 1109 Language of FatMouse
这道题目最让人头疼的就是该题的input怎么结束,因为它要求输入一个空行的时候则一串字符串输入结束,这就不得不让人绕个弯来解决这个问题. (注:本人习惯于使用C中的字符串操作,但是用到map要求使用s ...
- zoj1109 水题(大神绕道) Language of FatMouse
Language of FatMouse Time Limit: 10 Seconds Memory Limit:32768 KB We all know that FatMouse doe ...
- ZOJ 1108 & HDU 1160 - FatMouse's Speed
题目大意:给你n只老鼠的体重w和速度s,让你找出最长的子序列使得w[i] < w[j] 且 s[i] > s[j] (i < j).求最长序列的长度并输出该序列. LIS(Longe ...
随机推荐
- sql 语句操作,修改字段中字符串的一部分
update 表名 set 字段=replace(字段,‘替换的部分’,‘替换后的字符串’): update 表名 set A=replace( A, '海淀', '朝阳') where A like ...
- Eclipse 运行内存不足情况
在debug或者run 时 在VM arguments 处添加 -Xms512m -Xmx512m
- php配置COM组件正常运行
1. http://www.cnblogs.com/yuanke/p/4973824.html 在php.ini中 a. com.allow_dcom = true b. extension=php_ ...
- ios---setContentOffset
UIView * farmeView=[[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self. ...
- 两个已排序数组的合并-C语言
最近在纸上写一个已排序数组的合并时,花了超过预期的时间.仔细想想,这种要放到毕业找工作那会两下就出来了,原因还在于工作后对基础没有重视,疏于练习. 说开一点,现在搜索引擎的发达确实给问题的解决带来了便 ...
- 李开复:AlphaGo 若打败了世界冠军,意味着什么?
创新工场董事长李开复在知乎就AlphaGo与李世石的人机大战发表了自己看法,他认为四个月前的AlphaGo击败李世石基本不可能,不过这四个月AlphaGo进步很多,比赛应该很精彩.但是,无论这次结果如 ...
- SQLite-删除查询
SQLite -删除查询 SQLite DELETE查询用于从一个表删除现有记录.您可以使用WHERE子句删除查询删除选定行,否则所有记录将被删除. 语法: 删除查询的WHERE子句的基本语法如下: ...
- faster rcnn的改进方向
http://blog.csdn.net/linolzhang/article/details/74159463 http://blog.csdn.net/linolzhang/article/det ...
- 20道必须掌握的C++面试题
20道必须掌握的C++面试题 在面试C++方面的工作时,经常会遇到各种面试题,这对应聘人员的知识掌握能力要求较高.本文将为大家带来的就是20道必须掌握的C++面试题,不要错过哦! 问1:请用简单的语言 ...
- DLL动态库多次加载问题
原因涉及DLL加载和运行机制,主要有两点:1)DLL动态链接库无法独立运行,必须由一个应用程序进程加载到进程空间后才能使用.加载DLL的进程称为宿主进程.被加载的DLL属于宿主进程,不属于宿主进程内某 ...