Pagini recente » Cod sursa (job #3203951) | Cod sursa (job #764378) | Cod sursa (job #1756005) | Cod sursa (job #852695) | Cod sursa (job #1606299)
#include <cstdio>
#include <vector>
#define pb push_back
#define IN "hashuri.in"
#define OUT "hashuri.out"
#define MOD 666013
using namespace std;
vector <int> hashh[MOD];
int n;
FILE*fout=fopen (OUT, "w");
void read();
void solve();
void f_hash (int, int);
int main(){
read();
return 0;
}
void read(){
FILE*fin=fopen (IN, "r");
int i, a, b;
fscanf(fin, "%d", &n);
for (i=1; i<=n; ++i){
fscanf(fin, "%d %d", &a, &b);
f_hash (a, b);
}
fclose(fin);
return;
}
void f_hash (int op, int x){
int i, a;
if (op==1)//adaug elem x in multime
hashh[x%MOD].pb(x);
if (op==2)
{
a=x%MOD;
for (i=0; i<hashh[a].size(); ++i)
if (hashh[a][i]==x){
hashh[a].erase (hashh[a].begin() + i);
break;
}
}
if (op==3){
//caut elementul x
a=x%MOD;
for (i=0; i<hashh[a].size(); ++i)
if (hashh[a][i]==x){
fprintf (fout, "1\n");
return;
}
fprintf(fout, "0\n");
}
}