类似hash的题吧,翻译文稿。字典树搞的。
ac代码:
View Code
#include#include #include #include #include #include #include using namespace std;const int maxn=26;const int maxlen=3001;string tt,sss;struct node{ bool flg; string str; node *next[maxn]; node() { flg=false; str=""; for(int i=0;i next[num]==NULL) location->next[num]=new node(); location=location->next[num]; } location->str=tt; location->flg=true; } bool Search(string str) { node *location=root; for(int i=0;i next[num]==NULL) return false; location=location->next[num]; } if(location->flg) { sss=location->str; return true; } else return false; }}t;int main(){ char tmp[maxlen],ss[maxlen*2]; string s; gets(tmp);// puts(tmp); while(cin.getline(ss,maxlen*2)) { tt=s=""; for(int i=0;i ='a'&&ss[i]<='z') { s+=ss[i]; } else {// cout< <
欢迎批评指正。谢谢!