Pagini recente » Cod sursa (job #91718) | Cod sursa (job #1796360) | Cod sursa (job #1397923) | Cod sursa (job #1786845) | Cod sursa (job #463914)
Cod sursa(job #463914)
#include<fstream>
#include<list>
using namespace std;
const int MOD = 666013;
list<int> hash[MOD];
void add(int value)
{
int pos = value % MOD;
if (find(hash[pos].begin(), hash[pos].end(), value) == hash[pos].end())
hash[pos].push_back(value);
}
void del(int value)
{
int pos = value % MOD;
if (find(hash[pos].begin(), hash[pos].end(), value) != hash[pos].end())
hash[pos].erase(find(hash[pos].begin(), hash[pos].end(), value));
}
bool tell(int value)
{
int pos = value % MOD;
return (find(hash[pos].begin(), hash[pos].end(), value) != hash[pos].end()) ? 1 : 0;
}
int n;
int main()
{
ifstream fin("hashuri.in");
ofstream fout("hashuri.out");
fin >> n;
while (n--)
{
int type, value;
fin >> type >> value;
switch (type)
{
case 1:
add(value);
break;
case 2:
del(value);
break;
case 3:
fout << tell(value) << '\n';
}
}
}