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 ...
随机推荐
- 让大蛇(Python)帮你找工作 之增强版
前一段时间用Python写了个简单的网络爬虫,可以从某个求职网站上根据预先设置的条件一次性的爬取所有的职位信息,最近对该程序进行了一下完善,主要包括如下内容 (1)可以对爬取的结果再进行筛选 例如,你 ...
- mybatis 与 ehcache 整合[转]
1.简介 MyBatis 是支持普通SQL 查询,存储过程和高级映射的优秀持久层框架.MyBatis 消除了几乎所有的JDBC 代码和参数的手工设置以及结果集的检索. Ehcache 是现在最流行的纯 ...
- Win7下Qt5.2中使用OpenGL的glu函数库无法使用的解决方案
最近在Window7使用Qt5.2学习OpenGL时,出现了以OpenGL中glu开头的函数库无法使用的错误,例如: 'gluPerspective' was not declared ...
- 第一篇:数据库需求与ER建模
前言 在数据库建设过程中,哪一步最重要?绝大多数资料会告诉你,是需求分析阶段.这一步的好坏甚至直接决定数据库项目的成败. 需求分析阶段,也被称为ER建模(entity-relationship mod ...
- Linux shell入门基础(五)
五.bash运算及启动脚本 01.使用bash的命令历史 #history …… #set(显示所有的变量) | grep HIS HISTFILE=/root/.bash_history HISTF ...
- Hibernate HQL查询:
Hibernate HQL查询:Criteria查询对查询条件进行了面向对象封装,符合编程人员的思维方式,不过HQL(Hibernate Query Lanaguage)查询提供了更加丰富的和灵活的查 ...
- lucene查询排序结果原理总结
参考文章 Lucene3.0结果排序原理+操作+示例 Lucene的排序算法 一句话总结lucene排序算法是什么样的 关键几个概念 参考文档: http://lucene.apache.org/co ...
- 系统spt_values表--生成时间方便left join
时间处理我给你提供一个思路 系统有个spt_values表,可以构造一整个月的日期,然后左连接你统计好的数据,用CTE表构造多次查询 spt_values的超级经典的应用 http://www. ...
- 用js给html设置style
[html] view plaincopyprint? 原贴地址:<a href="http://heichong.iteye.com/blog/860698">htt ...
- linux list all users.
cat /etc/passwd sample of list users in linux. ref: Linux Command: List All Users In The System