Cod sursa(job #1050255)
Utilizator | Data | 8 decembrie 2013 13:55:37 | |
---|---|---|---|
Problema | Hashuri | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 2.25 kb |
#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
std::ifstream fin("hashuri.in");
std::ofstream fout("hashuri.out");
int n;
std::vector<int> hashuri[666013];
void citire()
{
int x, y;
fin>>n;
for(int i = 0; i < n; i++)
{
fin>>x>>y;
if(x == 1)
{
if(hashuri[y%666013].size())
{
bool found = false;
for(int i = 0; i < hashuri[y%666013].size(); i++)
{
if(hashuri[y%666013][i] == y)
{
found = true;
break;
}
}
if(!found)
{
hashuri[y%666013].push_back(y);
}
}
else
{
hashuri[y%666013].push_back(y);
}
}
else
if(x == 2)
{
if(hashuri[y%666013].size())
{
for(int i = 0; i < hashuri[y%666013].size(); i++)
{
if(hashuri[y%666013][i] == y)
{
hashuri[y%666013][i] = hashuri[y%666013].back();
hashuri[y%666013].pop_back();
break;
}
}
}
}
else
{
if(hashuri[y%666013].size())
{
bool found = false;
for(int i = 0; i < hashuri[y%666013].size(); i++)
{
if(hashuri[y%666013][i] == y)
{
found = true;
fout<<1<<'\n';
break;
}
}
if(!found)
{
fout<<0<<'\n';
}
}
else
{
fout<<0<<'\n';
}
}
}
}
int main()
{
citire();
return 0;
}