POJ2503 Babelfish
题目链接。
分析:
应当用字典树,但stl的map做很简单.
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cstring>
#include <queue> using namespace std; const int maxn = ; map<string, string> m; int main() {
char s[maxn], s1[maxn], s2[maxn]; while(gets(s), s[] != ) {
sscanf(s, "%s%s", s1, s2);
m[s2] = s1;
} while(gets(s) && s[] != ) {//这里s[0] != 0也要加上
if(m.count(s) == ) printf("eh\n");
else cout << m[s] << endl;
} return ;
}
POJ2503 Babelfish的更多相关文章
- POJ2503——Babelfish(map映射+string字符串)
Babelfish DescriptionYou have just moved from Waterloo to a big city. The people here speak an incom ...
- POJ2503 Babelfish map或者hash_map
POJ2503 这是一道水题,用Map轻松AC. 不过,可以拿来测一下字符串散列, 毕竟,很多情况下map无法解决的映射问题需要用到字符串散列. 自己生成一个质数, 随便搞一下. #include&l ...
- POJ2503——Babelfish
Description You have just moved from Waterloo to a big city. The people here speak an incomprehensib ...
- POJ2503(Babelfish)--简单字典树
思路:就是用一个字典树翻译单词的问题,我们用题目中给出的看不懂的那些单词建树,这样到每个单词的叶子结点中存放原来对应的单词就好. 这样查询到某个单词时输出叶子结点存的就行,查不到就"en&q ...
- poj_2503(map映射)
题目链接poj2503 Babelfish Time Limit: 3000MS Memory Limit: 65536K Total Submissions: 38820 Accepted: ...
- POJ2503:Babelfish
浅谈\(Trie\):https://www.cnblogs.com/AKMer/p/10444829.html 题目传送门:http://poj.org/problem?id=2503 \(Trie ...
- Babelfish(二分查找,字符串的处理略有难度,用sscanf输入)
Babelfish Time Limit: 3000MS Memory Limit: 65536K Total Submissions: 28581 Accepted: 12326 题目链接: ...
- poj 2503:Babelfish(字典树,经典题,字典翻译)
Babelfish Time Limit: 3000MS Memory Limit: 65536K Total Submissions: 30816 Accepted: 13283 Descr ...
- POJ 2503 Babelfish
Babelfish Time Limit: 3000MS Memory Limit: 65536K Total Submissions: 28766 Accepted: 12407 Descripti ...
随机推荐
- android开发launcher
1. launcher是桌面应用程序 一. android.intent.category.LAUNCHER与android.intent.category.HOME的差别? android ...
- pythonQQ邮件
http://www.cnblogs.com/lonelycatcher/archive/2012/02/09/2343463.html http://blog.csdn.net/imzoer/art ...
- cocos2d-x项目过程记录(ios和android设备的适配)
(原创作品,欢迎转载,注明出处,谢谢:http://www.cnblogs.com/binxindoudou/admin/EditPosts.aspx?postid=3213645) 1.原理分析的博 ...
- IOS 获取通讯录中信息
获取通讯录中信息 一. 我们设置一个ABAddressBookRef类型的属性addressBook. 二. 要获得通讯录中的信息,我们需要获取访问通讯录的权限. 在运行下面的获取权限的方法的时候,系 ...
- [转] 怎样快速而优雅地遍历 JavaScript 数组
我们一般用循环来遍历数组,而循环一直是 JavaScript 性能问题的常见来源,有时循环用得不好会严重降低代码的运行速度.例如,遍历数组时,我们会很自然地写出下面这种代码: // 未优化的代码1 v ...
- [转] 不要被C++“自动生成”所蒙骗
http://www.cnblogs.com/fanzhidongyzby/archive/2013/01/12/2858040.html C++对象可以使用两种方式进行创建:构造函数和复制构造函数. ...
- Day7 - Python基础7 面向对象编程进阶
Python之路,Day7 - 面向对象编程进阶 本节内容: 面向对象高级语法部分 经典类vs新式类 静态方法.类方法.属性方法 类的特殊方法 反射 异常处理 Socket开发基础 作业:开发一个 ...
- java.lang.ClassCastException
是指类型转换出错 当前者的域小于后者的时候出现 譬如说:前者A是子类的对象,而后者B是父类的对象 若使用A = B;就会抛出java.lang.ClassCastException List<C ...
- Webview的使用和注意事项
1.webView是一个展示web网页的控件,继承 AbsoluteLayout 2.webview的俩个回调应用层: 1)webViewClient 这个对象的创建 WebViewClient my ...
- (转)MySQL数据库命名规范及约定
一.[操作规范]1. 如无备注,则表中的第一个id字段一定是主键且为自动增长:2. 如无备注,则数值类型的字段请使用UNSIGNED属性:3. 如无备注,排序字段order_id在程序中默认使用降序排 ...