字符串哈希水题
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <map>
using namespace std;
#define debug cout<<"***"<<endl;
map <int,int> m1,m2;
const int maxn=105000;
char spell[maxn][100];
char magic[maxn][100];
int f1[maxn];
int f2[maxn];
int pos1=1,pos2=1;
unsigned int BKDRHash(char *str)
{
unsigned int seed = 131;
unsigned int hash = 0;
while (*str){
hash = hash * seed + (*str++);
}
return (hash & 0x7FFFFFFF);
}
void init(){
for(int i=1;i<pos1;i++){
m1[BKDRHash(magic[i])]=i;
m2[BKDRHash(spell[i])]=i;
//f1[BKDRHash(magic[i])]=i;debug;
//f2[BKDRHash(spell[i])]=i;
}
}
int main(){
memset(f1,-1,sizeof(f1));
memset(f2,-1,sizeof(f2));
while(scanf("%s",magic[p