Pagini recente » Cod sursa (job #2515168) | Cod sursa (job #2548191) | Cod sursa (job #3786) | Cod sursa (job #224355) | Cod sursa (job #2761663)
#include <iostream>
#include <fstream>
#include <vector>
using namespace std;
int numar_operatii, operatie, numar, bucket;
vector <int> multime[666013];
int main()
{
ifstream fin("date.in");
ofstream fout("date.out");
fin >> numar_operatii;
for(int i = 0; i < numar_operatii; i++)
{
fin >> operatie;
fin >> numar;
if(operatie == 1)
{
bucket = numar % 666013;
int ok = 0;
for(int j = 0; j < multime[bucket].size()&&ok == 0; j++)
if(multime[bucket][j] == numar)
ok = 1;
if(!ok)
multime[bucket].push_back(numar);
}
else if(operatie == 2)
{
bucket = numar % 666013;
int pozitie = -1;
for(int j = 0; j < multime[bucket].size()&&pozitie == -1; j++)
if(multime[bucket][j] == numar)
pozitie = j;
if(pozitie != -1)
multime[bucket].erase(multime[bucket].begin() + pozitie);
}
else
{
bucket = numar % 666013;
int ok = 0;
for(int j = 0; j < multime[bucket].size()&&ok == 0; i++)
if(multime[bucket][j] == numar)
ok = 1;
fout << ok << '\n';
}
}
return 0;
}