Pagini recente » Cod sursa (job #1304667) | Cod sursa (job #783717) | Cod sursa (job #1432792) | Cod sursa (job #972911) | Cod sursa (job #1224703)
#include <fstream>
#include <vector>
using namespace std;
ifstream f("hashuri.in");
ofstream g("hashuri.out");
const int mod = 666013;
vector <int> h[mod];
int main()
{
int p,x,n,key,j;
bool ok;
f>>n;
for(int i=0;i<n;++i) {
ok = 0;
f>>p>>x;
key = x%mod;
for(j=0;j<(int)h[key].size();++j) {
if (h[key][j]==x) {
ok = 1;
break;
}
}
if (p==1) {
if (ok==0) {
h[key].push_back(x);
}
} else if (p==2) {
if (ok==1) {
h[key][j] = h[key][h[key].size()-1];
h[key].resize(h[key].size()-1);
}
} else if (p==3) {
g<<ok<<'\n';
}
}
return 0;
}