HDU 1075 What Are You Talking About
2014-07-07 14:25
375 查看
字典树
看题库上说这是字典树,不过被我水过去了。
题意是说用对应的字典,翻译出火星文。
each line will contain at most 3000 characters.
看到这句话我就安心了。Time Limit: 10000/5000 MS (Java/Others)
果断用map 来水了。还真AC了。3296MS 。本来是想巩固一下字典树的,不过……。
看题库上说这是字典树,不过被我水过去了。
题意是说用对应的字典,翻译出火星文。
each line will contain at most 3000 characters.
看到这句话我就安心了。Time Limit: 10000/5000 MS (Java/Others)
果断用map 来水了。还真AC了。3296MS 。本来是想巩固一下字典树的,不过……。
#include<cstdio> #include<cstring> #include<string> #include<queue> #include<algorithm> #include<queue> #include<map> #include<stack> #include<iostream> #include<list> #include<set> #include<cmath> #define INF 0x7fffffff #define eps 1e-6 using namespace std; map<string,string>word; int main() { string a,b; word.clear(); while(cin>>a,a!="START"); while(cin>>a,a!="END") { cin>>b; word[b]=a; } while(cin>>a,a!="START"); char str[3001]; gets(str); while(gets(str)) { if(strcmp(str,"END")==0)return 0; int len=strlen(str); char s[3001],j=0; for(int i=0;i<len;i++) { if(str[i]>='a'&&str[i]<='z') s[j++]=str[i]; else { s[j]='\0';j=0; b=s; if(word.find(b)==word.end()) cout<<b; else cout<<word[b]; printf("%c",str[i]); } } printf("\n"); } }
相关文章推荐
- Hdu 1075 What Are You Talking About
- 杭电hdu 1075 What Are You Talking About 字典树的应用
- HDU1075——What Are You Talking About
- hdu 1075 What Are You Talking About
- HDU 1075 What Are You Talking About(map+字符串)
- hdu 1075 What Are You Talking About
- hdu 1075 What Are You Talking About (字典树)
- HDU 1075 What Are You Talking About (map解法+Trie解法)
- hdu 1075 What Are You Talking About
- HDU 1075 What Are You Talking About
- HDU 1075 What Are You Talking About
- HDU 1075 What Are You Talking About
- HDU 1075 What Are You Talking About (STL, 字典树)
- hdu 1075 What Are You Talking About
- hdu 1075 What Are You Talking About(字典树)
- HDU 1075 What Are You Talking About(Tire树)
- HDU-1075 What Are You Talking About
- hdu 1075 What Are You Talking About< map<string,string> >
- hdu-1075-What Are You Talking About
- HDU 1075 What Are You Talking About // 字符串映射,Trie