[字典树]hdu 1075
来源:互联网 发布:java jdbcutils 编辑:程序博客网 时间:2024/05/18 20:52
/**[字典树]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;}