Mai intai trebuie sa te autentifici.
Cod sursa(job #681176)
| Utilizator | Data | 16 februarie 2012 18:51:17 | |
|---|---|---|---|
| Problema | Hashuri | Scor | 40 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.71 kb |
#include<cstdio>
#include<vector>
using namespace std;
int t,act,val,hval,H=100009;
vector<int> hash[1000010];
int main()
{
vector<int>::iterator it;
freopen("hashuri.in","r",stdin);
freopen("hashuri.out","w",stdout);
scanf("%d",&t);
for(;t--;)
{
scanf("%d%d",&act,&val);
hval=val%H;
for(it=hash[hval].begin();it!=hash[hval].end();it++)
{
if(*it==val)break;
}
if(act==1)
{
if(it==hash[hval].end())hash[hval].push_back(val);
}
else if(act==2)
{
if(it!=hash[hval].end())
{
*it=*hash[hval].end();
hash[hval].pop_back();
}
}
else if(act==3)
{
if(it!=hash[hval].end())printf("1\n");
else printf("0\n");
}
}
}