Pagini recente » Cod sursa (job #270566) | Cod sursa (job #1040674) | Cod sursa (job #1681255) | Cod sursa (job #2237719) | Cod sursa (job #1583557)
#include <iostream>
#include <fstream>
#include <vector>
using namespace std;
ifstream f("hashuri.in");
ofstream g("hashuri.out");
const int rest = 666013;
int n;
vector <int> M[rest];
int Check(int x)
{
int Line = x%rest;
for(int i = 0; i < (int)M[Line].size(); i++)
if(x == M[Line][i]) return i+1;
return 0;
}
void Add(int x)
{
int Line = x%rest;
if(!Check(x)) M[Line].push_back(x);
}
void Delete(int x)
{
int Line = x%rest;
int i = Check(x) - 1;
if(i != -1) M[Line].erase(M[Line].begin() + i);
}
int main()
{
f>>n;
while(n--)
{
int opt, x;
f>>opt>>x;
if(opt == 1) Add(x);
if(opt == 2) Delete(x);
if(opt == 3)
{
if(Check(x)) g<<1<<'\n';
else g<<0<<'\n';
}
}
return 0;
}