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 ...
随机推荐
- 总结 - 常见的JavaScript兼容性问题
添加事件的方法 (元素, 绑定的事件类型, 事件触发的方法) addHandler: function (element, type, handler) { if (element.addEventL ...
- Hibernate通过实体对象对应数据库表信息
Hibernate通过实体对象对应数据库表信息,包括:数据库表名称.主键列名.非主键列名等. 获取对象映射缓存管理类: AbstractEntityPersister aep = (AbstractE ...
- 使用PlSQLDeveloper工具查询Oracle会话数
PlSQLDeveloper工具提供了会话管理功能. 能够查询会话内容.杀死会话.查看会话SQL等操作. 常用的会话查询SQL如下: -- 查询所有会话 select * from v$session ...
- 使用callabestatement接口调用存储过程
- 517 Super Washing Machines 超级洗衣机
详见:https://leetcode.com/problems/super-washing-machines/description/ C++: class Solution { public: i ...
- C. Tennis Championship dp递推 || 找规律
http://codeforces.com/contest/735/problem/C C. Tennis Championship time limit per test 2 seconds mem ...
- PKU_campus_2018_H Safe Upper Bound
思路: 题目链接http://poj.openjudge.cn/practice/C18H/ 用2147483647除以最大素因子. 这里用了Pollard_rho因子分解算法,模板参考了http:/ ...
- 网页尺寸scrollHeight/offsetHeight
scrollHeight和scrollWidth,获取网页内容高度和宽度. 一.针对IE.Opera: scrollHeight 是网页内容实际高度,可以小于 clientHeight. 二.针对NS ...
- xcopy递归拷贝
递归拷贝 ::xcopy SOURCE_DIR DES_DIR\ /s SOURCE_DIR后面不需要加反斜杠
- PMP项目管理学习笔记(12)——范围管理之创建工作分解结构(WBS)
创建工作分解结构过程是范围管理知识领域中最重要的过程,因为要在此过程明确所要做的全部工作 输入:收集需求和定义范围过程的输出会成为创建工作分解结构过程的输入(需求文档.组织资产过程.项目范围说明书) ...