Pagini recente » Cod sursa (job #2176380) | Cod sursa (job #1724406) | Cod sursa (job #1860514) | Cod sursa (job #2885654) | Cod sursa (job #2040799)
#include <fstream>
#include <vector>
using namespace std;
ifstream cin("hashuri.in");
ofstream cout("hashuri.out");
const int mod = 666013;
int q, t, x;
vector<int> h[mod];
bool find(int x) {
for(auto it: h[x % mod]) {
if(it == x)
return true;
}
return false;
}
void add(int x) {
if(!find(x)) {
h[x % mod].push_back(x);
}
}
void remove(int x) {
vector<int>::iterator it;
for(it = h[x % mod].begin(); it != h[x % mod].end(); ++it) {
if(*it == x) {
h[x % mod].erase(it);
return;
}
}
}
int main() {
cin >> q;
while (q--) {
cin >> t >> x;
if(t == 1)
add(x);
else if(t == 2)
remove(x);
else
cout << find(x) << "\n";
}
return 0;
}