Pagini recente » Cod sursa (job #817881) | Cod sursa (job #634966) | Cod sursa (job #2268448) | Cod sursa (job #2290948) | Cod sursa (job #1101626)
#include<iostream>
#include<fstream>
#include<vector>
using namespace std;
ifstream fin("hashuri.in");
ofstream fout("hashuri.out");
const int MAXN = 666013;
vector<int> v[MAXN];
vector<int>::iterator aux;
int m, c, x;
vector<int>::iterator found(int y) {
int pos = y % MAXN;
vector<int>::iterator it;
for(it = v[pos].begin(); it != v[pos].end(); it++) {
if(*it == x) {
return it;
}
}
return v[pos].end();
}
void add(int y) {
int pos = y % MAXN;
v[pos].push_back(y);
}
void del(int y) {
int pos = y % MAXN;
vector<int>::iterator it = found(y);
if(it != v[pos].end()) {
v[pos].erase(it);
}
}
int main() {
fin >> m;
while(m) {
m--;
fin >> c >> x;
if(c == 1) {
if(found(x) == v[x%MAXN].end()) {
add(x);
}
continue;
}
if(c == 2) {
del(x);
continue;
}
if(c == 3) {
if(found(x) == v[x%MAXN].end()) {
fout << 0 << '\n';
}
else {
fout << 1 << '\n';
}
continue;
}
}
fin.close();
fout.close();
return 0;
}