Mai intai trebuie sa te autentifici.
Cod sursa(job #2895235)
Utilizator | Data | 28 aprilie 2022 20:32:18 | |
---|---|---|---|
Problema | Hashuri | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.84 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream f("hashuri.in");
ofstream g("hashuri.out");
#define cin f
#define cout g
const int Mod = 1000003;
list < int > Hash[Mod];
int main()
{
int n; cin >> n;
while(n --)
{
int op, x, poz;
cin >> op >> x;
poz = x % Mod;
if(op == 1)
{
bool ok = false;
for(auto it : Hash[poz])
if(it == x)
{
ok = true;
break;
}
if(ok == false)
Hash[poz].push_back(x);
}
else if(op == 2)
{
for(auto it = Hash[poz].begin(); it != Hash[poz].end(); it ++)
if(*it == x)
{
Hash[poz].erase(it);
break;
}
}
else
{
bool ok = false;
for(auto it : Hash[poz])
if(it == x)
{
ok = true;
break;
}
if(ok == true)
cout<<1<<'\n';
else
cout<<0<<'\n';
}
}
return 0;
}