#include <stdio.h>
#include <iostream>
#include <string.h>
using namespace std;
const int maxn=2500*2500+3;
const int maxd=15;
const int seed=2500*2500+3;//是一个大素数
typedef long long LL;
struct HASH//哈希表
{
int head[seed];
int size;
struct NODE
{
int key;
int value;
int next;
}edges[maxn];
void init()
{
memset(head,-1,sizeof(head));
size=0;
}
void insert(int key,int value)//插入值
{
int h=key%seed;
for(int i=head[h];i!=-1;i=edges[i].next)
{
if(edges[i].key==key)
{
edges[i].value=max(value,edges[i].value);
return;
}
}
edges[size].key=key;
edges[size].value=value;
edges[size].next=head[h];
head[h]=size++;
}
int search(int key)//寻找
{
int h=key%seed;
for(int i=head[h];i!=-1;i=edges[i].next)
{
if(edges[i].key==key)
{
return edges[i].value;
}
}
return -1;
}
}tr;
const int MAXN=1<<20;
const int HASH = 1000007;
struct hashmap//建立哈希表
{
LL a[MAXN];
int head[HASH],next[MAXN],size;
void init() //初始化
{
memset(head,-1,sizeof(head));
size=0;
}
bool find(LL val) //查找一个元素是否在哈希表内
{
int tmp = (val%HASH + HASH)%HASH;
for(int i = head[tmp]; i!=-1; i=next[i])
if(val==a[i]) return true;
return false;
}
void add(LL val) //添加元素到哈希表中
{
int tmp =(val%HASH+HASH)%HASH;
if(find(val)) return;
a[size]=val;
next[size]=head[tmp];
head[tmp]=size++;
}
} h1;