Mai intai trebuie sa te autentifici.
Cod sursa(job #724076)
Utilizator | Data | 26 martie 2012 10:48:19 | |
---|---|---|---|
Problema | Hashuri | Scor | 70 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.81 kb |
#include<fstream>
#include<list>
#include<algorithm>
#define _B 1748596 //lame
using namespace std;
int main()
{
ifstream fin("hashuri.in");
ofstream fout("hashuri.out");
static list<int> hash_t[_B];
int nOp; fin>>nOp;
for (int i=1;i<=nOp;i++)
{
int op, val;
fin>>op>>val;
list<int>::iterator it;
switch (op)
{
case 1: hash_t[val%_B].push_back(val); break;
case 2:
it=find(hash_t[val%_B].begin(),hash_t[val%_B].end(),val);
if (it!=hash_t[val%_B].end()) hash_t[val%_B].erase(it); break;
case 3:
if (find(hash_t[val%_B].begin(),hash_t[val%_B].end(),val)==hash_t[val%_B].end()) fout<<"0\n";
else fout<<"1\n";
}
}
return 0;
}