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 ...
随机推荐
- linux中用户组和用户
linux中用户组和用户 1.介绍 在我们的linux系统,有很多用户组,也可以手动创建用户组,不同的用户组下面有很多的用户. 2.创建用户组及有关的命令 groupadd phpzu:创建一个php ...
- 在HTML页面中实时获取新消息的方法 “JavaScript中的setInterval用法”
JavaScript中的setInterval用法(资料来源:博主---八神吻你 ) setInterval动作的作用是在播放动画的时,每隔一定时间就调用函数,方法或对象.可以使用本动作更新来自数 ...
- vue项目node升级后,node-saas报错解决办法
ERROR in ./node_modules/_extract-text-webpack-plugin@3.0.2@extract-text-webpack-plugin/dist/loader.j ...
- 在线编译器Coding Ground
http://www.tutorialspoint.com/codingground.htm Free Online IDE and Terminal - Edit, Compile, Execute ...
- 初学.net增删改查
分页显示 DAL: public List GetListByPager(int PageIndex, int PageSize, out int RowCount) { string sql = & ...
- 浅议block实现原理,block为什么使用copy关键字?
1.block是一个特殊的oc对象,建立在栈上,而不是堆上,这么做一个是为性能考虑,还有就是方便访问局部变量. 2.默认Block使用到的局部变量会被copy,而不是retain.所以,他无法改变局部 ...
- TextView、EditText
1.TextView 显示文本信息 常用属性: layout_width/height 控件的宽/高 width/heigth 文本区域的宽/高 text 显示的文本 textSi ...
- 【学习笔记】C++ cout 输出小数点后指定位数
在C中我们可以使用 printf("%.2lf",a);但在C++中是没有格式操作符的,该如何操作: C++使用setprecision()函数,同时必须包含头文件iomanip, ...
- #error和#line使用分析
#error的用法 #error用于生成一个编译错误消息 用法:error message(不需要用双引号包围) #error编译指示字用于自定义程序员特有的编译错误,消息类似的 #warning用于 ...
- Android原生系统API自带dp、px、sp单位转换
Android系统中自带的Api中可以使用TypedValue进行单位转换 1,调用系统api转换单位 // 获得转换后的px值 float pxDimension = TypedValue.appl ...