HDU 1251

来源:互联网 发布:菜鸟是什么意思网络 编辑:程序博客网 时间:2024/05/18 15:57

字典树,map水过。

#include <cstdio>#include <cstring>#include <map>#include <iostream>#include <algorithm>using namespace std;map<string,int> mp;char st[1000];int main(){    mp.clear();    while(gets(st)){        if(st[0]=='\0') break;        int len = strlen(st);        for(int i=len-1;i>=0;i--){            mp[st]++;            st[i]='\0';        }    }    while(gets(st)){        printf("%d\n",mp[st]);    }    return 0;}
0 0
原创粉丝点击