Dictionary tree
According to the Question Bank, this is a dictionary tree, but I have passed the water.
The meaning is to use the corresponding dictionary to translate the fire text.
Each line will contain at most 3000 characters.
I feel at ease when I see this sentence.Time Limit: 10000/5000 MS (Java/Others)
Make sure you use map. Actually AC. 3296 Ms. I wanted to consolidate the dictionary tree, .......
#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-6using 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"); }}