您的位置:首页 > 其它

[字典树]hdu 1075

2012-08-08 14:16 288 查看
/**
[字典树]hdu 1075 map水过(PE了两次)
*/
#include <stdio.h>
#include <string.h>
#include <string>
#include <map>
#include <algorithm>

using namespace std;
int main()
{
int i,j;
char s[11],s2[11],str[3001];
gets(s);
map<string,string> mp;
while(scanf("%s",s))
{
if(strcmp(s,"END") == 0)
break;
scanf("%s",s2);
mp[string(s2)] = string(s);
}
getchar();
gets(str);
while(gets(str))
{
if(strcmp(str,"END") == 0)
break;
for(i = 0; str[i]; ++i)
{
if(str[i] < 'a' || str[i] > 'z')
{
printf("%c",str[i]);
continue;
}
for(j = 0; str[i] <= 'z' && str[i] >= 'a';++i,++j)
s[j] = str[i];
--i;
s[j] = 0;
if(mp.find(string(s)) != mp.end())
printf("%s",mp[string(s)].c_str());
else
printf("%s",s);
}
puts("");
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: