Pagini recente » Cod sursa (job #2967508) | Diferente pentru implica-te/arhiva-educationala intre reviziile 182 si 183 | simojir | Cod sursa (job #406912) | Cod sursa (job #3130945)
#include<bits/stdc++.h>
using namespace std;
ifstream in("sea.in");
ofstream out("sea.out");
vector <vector <int>> hashh;
int p = 116351, k, c, val, x;
void ins(int x, int val)
{
for(int j = 0; j < hashh[x].size(); j++)
if(hashh[x][j] == val)
return;
hashh[x].push_back(x);
}
void del(int x)
{
for(int j = 0; j < hashh[x].size(); j++)
if(hashh[x][j] == val)
{
hashh[x].erase(hashh[x].begin() + j);
break;
}
}
int main()
{
in >> k;
for(int i = 1; i <= k; i++)
{
in >> c >> val;
x = val % p;
while(hashh.size() <= x)
hashh.push_back({});
switch(c)
{
case 1:
{
ins(x, val);
break;
}
case 2:
{
del(x);
break;
}
case 3:
{
int j;
for(j = 0; j < hashh[x].size(); j++)
if(hashh[x][j] == val)
{
out << 1 << endl;
break;
}
if(j == hashh[x].size())
out << 0 << endl;
break;
}
}
}
return 0;
}