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 ...
随机推荐
- Flashback Query、Flashback Table(快速闪回查询、快速闪回表)
Flashback Query闪回查询 flashback query是基于undo表空间的闪回,与之相关的参数如下: SQL> show parameter undo NAME ...
- C\C++代码优化的27个建议
1. 记住阿姆达尔定律: funccost是函数func运行时间百分比,funcspeedup是你优化函数的运行的系数. 所以,如果你优化了函数TriangleIntersect执行40%的运行时间, ...
- Undefined symbols for architecture i386
这个错误的发生原因一般是“XXX”这个文件(类库)虽然引入了工程中,但是由于种种原因(常见于多人开发,svn同步不规范)导致“XXX”并未被添加到project.pbxproj这个文件中. 解决方法是 ...
- EXCEL表格常用函数使用的难点
1. INDIRECT(ref_text,逻辑值) 返回由文本字符串指定的引用.此函数立即对引用进行计算,并显示其内容.ref_text,文本引用说明, (1) A1-样式的引用(逻辑值,T,缺省) ...
- C#-高血压生活习惯数据模拟
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace test ...
- Dhroid框架配置
1.将dhroid文件夹作为一个Module导入,dhroid下载地址 2.在build.gradle中的dependencies节点中添加compile project(':dhroid') dep ...
- C# 汉字的字符串截取指定字节的长度
int index = 0; int setCharCount = 74; string str1 = "三星 SCH-I829 电信3G手机(优 ...
- target,currentTarget,delegateTarget,srcElement
第一种情况:就是IE9+和其他现代浏览器,支持addEventListener方法.其结果是: this总是等于currentTarget currentTarget总是事件监听者 target总是事 ...
- iOS GorupBy
转自: IOS 数组分组 Grouped NSArray 1 2 3 4 5 6 7 8 NSMutableSet *set=[NSMutableSet set]; [_list enumera ...
- 通过dbcp链接池对数据库操作报 Cannot create PoolableConnectionFactory (Could not create connection to database server. Attempted reconnect 3 times. Giving up.)--解决方案
org.springframework.transaction.CannotCreateTransactionException: Could not open JDBC Connection for ...