poj 2503
来源:互联网 发布:反快看漫画知乎 编辑:程序博客网 时间:2024/05/20 21:24
无限感慨啊,这道题半年前就做过,无限wa就放弃了,今天又重做这题,依旧没变无限wa,只不过这次敲了20分钟就完了,代码也简洁了,哈希函数直接自己构造的,比之前熟练了,然后检查,历经一个小时之后,才发现把'eh'当成了'en',改后ac,300ms,然后再翻出之前的代码,果然是同样的错误,回想起半年前的那一整个下午,真是欲哭无泪啊
#include <iostream>#include <cstdio>#include <cstring>using namespace std;const int maxn=100000+3;int head[maxn],next[maxn];char s1[maxn][15],s2[maxn][15];int hash(char *s){int k=0;while(*s!='\0'){k=((k*26)%maxn+(*s-'a'))%maxn;s++;}return k;}int main(){char s[50];memset(head,-1,sizeof(head));int i=0;while(gets(s)){if(sscanf(s,"%s %s",s1[i],s2[i])!=2) break;int k=hash(s2[i]);next[i]=head[k];head[k]=i;i++;}while(gets(s)){int k=hash(s);for(i=head[k];i!=-1;i=next[i]){if(strcmp(s2[i],s)==0){printf("%s\n",s1[i]);break;}} if(i==-1) printf("eh\n");}return 0;}
- Poj 2503
- poj 2503
- POJ 2503
- POJ 2503
- poj 2503
- poj 2503
- POJ 2503
- poj-2503
- poj 2503
- poj- 2503
- poj 2503
- POJ 2503
- POJ-----2503
- poj 2503 Babelfish
- POJ 2503 Babelfish(HASH)
- POJ 2503 //map
- poj 2503 Babelfish
- POJ 2503 Babelfish
- schema教程
- Compare LC and HE configure for HM3.0 of HEVC(H.265)
- 算是日记吧
- iOS的View之间的数据传递
- ps抠图
- poj 2503
- 怎样结合节日进行外贸销售
- java的Random类
- OS课设之Gtk+
- 大话设计模式_迭代器模式
- struct file struct inode
- so
- 自己机器上把latex文档转成word的doc格式
- 通过网络链接优化实现搜索引擎优化