hdu 1075
#include<stdio.h>
#include<string.h>
#include<string>
#include<iostream>
#include<algorithm>
#include<map>
using namespace std;
map<string,string>mymap;
int main() {
int i,j,k,n,m;
char s[4000],str[30],str2[30];
string str1;
scanf("%s",str);
while(scanf("%s",str),strcmp(str,"END")) {
scanf("%s",str2);
mymap[str2]=str;
}
getchar();
gets(s);
while(gets(s),strcmp(s,"END")) {
k=0;
for(i=0;s[i];i++)
if(s[i]>='a'&&s[i]<='z')
str[k++]=s[i];
else {
if(k==0) {
printf("%c",s[i]);
continue;
}
str[k++]=0;
str1=mymap[str];
strcpy(str2,str1.c_str());//或者直接进行长度比较str1.length();
if(strlen(str2)==0)
printf("%s",str);
else
cout<<str1;
printf("%c",s[i]);
k=0;
}
printf("\n");
}
return 0;
}
hdu 1075的更多相关文章
- HDU 1075 What Are You Talking About(Trie的应用)
What Are You Talking About Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 102400/204800 K ...
- hdu 1075 (map)
http://acm.hdu.edu.cn/showproblem.php?pid=1075 What Are You Talking About Time Limit: 10000/5000 MS ...
- hdu 1075 What Are You Talking About
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1075 题意:比较简单,易懂,这里不做说明. 解法:第一种方法:用map映射,耗时1000+ms:第二种 ...
- 字典树 HDU 1075 What Are You Talking About
http://acm.hdu.edu.cn/showproblem.php?pid=1075 ;}
- 题解报告:hdu 1075 What Are You Talking About
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1075 Problem Description Ignatius is so lucky that he ...
- HDU 1075 What Are You Talking About (Trie)
What Are You Talking About Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 102400/204800 K ...
- hdu 1075:What Are You Talking About(字典树,经典题,字典翻译)
What Are You Talking About Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 102400/204800 K ...
- hdu 1075 二分搜索
还是写一下,二分搜索好了 这道题开数组比较坑... 二分,需要注意边界问题,例如:左闭右闭,左闭右开,否则查找不到or死循环 先上AC代码 #include<iostream> #incl ...
- HDOJ/HDU 1075 What Are You Talking About(字符串查找翻译~Map)
Problem Description Ignatius is so lucky that he met a Martian yesterday. But he didn't know the lan ...
- hdu 1075 What Are You Talking About(字典树)
刚学的字典树,代码写得很不熟练.写法上也没有什么特别的优化,就是以1A为第一目标! 可惜还是失败了. 少考虑了一种情况,就是一个单词是另一个单词前缀的问题,写了好久,还是没有1A.不过感觉对字典树有了 ...
随机推荐
- TCP模型,控制标志,握手,挥手,长连接*
1. TCP协议 Transmission Control Protocol,传输控制协议 面向连接的协议 需要三次握手建立连接 需要四次挥手断开连接 TCP报头最小长度:20字节 2.模型图 3.T ...
- overlaps the location of another project Zendstudio导入已经存在的目录
转 http://blog.csdn.net/kdchxue/article/details/50633745 最近弄zendstuido导入已经存在的项目,找了很多地方终于找到了导入的方法,特别记录 ...
- C. Dasha and Password 预处理 + dp
http://codeforces.com/contest/761/problem/C 对于每一个字符串,可以预处理出其到达数字,字母,和特殊符号所需的最小步数. 然后就是在n个东西中,选出数字.字母 ...
- mybatis的mapper.xml文件细节
- CF916C Jamie and Interesting Graph
思路:构造 实现: #include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n ...
- Elasticsearch--集群管理_别名&插件&更新API
目录 使用索引别名 别名 创建别名 修改别名 合并命令 获取所有别名 移除别名 别名中过滤 别名和路由 Elasticsearch插件 基础知识 安装插件 移除插件 更新设置API 使用索引别名 通过 ...
- .NET 出现参数化查询 需要参数但未提供该参数的错误
1.问题的来源 在.NET或者C#中,我们一般执行sql语句的话,推荐使用参数化查询,这样可以避免sql注入的攻击,但是,我在使用参数化查询的时候 出现了以下的错误,详细如下图: 图一这是写sql语句 ...
- IntentFilter的相关问题解析
IntentFilter是配合Intent而生的,你有目标行动或者结果,那么那些行动和结果就会有他完成的特定要求,这些要求就是IntentFilter,可以理解为Intent和IntentFilter ...
- 使用JDBC创建出版社和书籍管理系统
1.需求 已知如下两个表: publisher id name(唯一) address book id isbn name publisher_id 欢迎进入书籍管理系统 1.出版社管理:增.删(na ...
- python day one
今日内容: python基础: 一 编程语言 什么是编程语言? 上面提及的能够被计算机所识别的表达方式即编程语言,语言是沟通的介质,而编程语言是程序员与计算机沟通的介质.在编程的世界里,计算机更像是人 ...