Pagini recente » Cod sursa (job #1335155) | Cod sursa (job #38892) | Cod sursa (job #1604745) | Cod sursa (job #2906739) | Cod sursa (job #2109119)
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000007
list<int> table[MOD];
void Delete(int N)
{
int hashCode = N % MOD;
for(auto it = table[hashCode].begin(); it != table[hashCode].end(); it++)
{
if(*it == N)
{
table[hashCode].erase(it);
return;
}
}
}
bool Find(int N)
{
int hashCode = N % MOD;
for(auto it = table[hashCode].begin(); it != table[hashCode].end(); it++)
{
if(*it == N)
{
return true;
}
}
return false;
}
void Insert(int N)
{
int hashCode = N % MOD;
if(!Find(N))
{
table[hashCode].push_back(N);
}
}
int main()
{
freopen("hashuri.in", "r", stdin);
freopen("hashuri.out", "w", stdout);
int T, Q, x; scanf("%d", &T);
while(T--)
{
scanf("%d %d", &Q, &x);
if(Q == 1) Insert(x);
if(Q == 2) Delete(x);
if(Q == 3) printf("%d\n", Find(x));
}
return 0;
}