Pagini recente » Cod sursa (job #1525886) | Cod sursa (job #3219585) | Cod sursa (job #1912259) | Cod sursa (job #1248574) | Cod sursa (job #3129420)
#include <fstream>
#include <vector>
using namespace std;
ifstream f("hashuri.in");
ofstream g("hashuri.out");
int main()
{
const int p = 9973; //cel mai mare numar prim de care am dat
vector <vector <int>> liste;
int q;
f >> q;
for(int i = 1; i <= q; i++)
{
int optiune, x;
f >> optiune >> x;
int val = x % p;
while(liste.size() <= val)
liste.push_back({}); //trebuie sa alocam spatiu pt liste
switch(optiune)
{
case 1:
{
bool gasit = false;
for(int j = 0; j < liste[val].size() && !gasit; j++)
if(liste[val][j] == x)
gasit = true;
if(!gasit) liste[val].push_back(x);
break;
}
case 2:
{
for(int j = 0; j < liste[val].size(); j++)
if(liste[val][j] == x)
{
liste[val].erase(liste[val].begin() + j);
break;
}
break;
}
case 3:
{
bool gasit = false;
for(int j = 0; j < liste[val].size() && !gasit; j++)
if(liste[val][j] == x)
gasit = true;
if(gasit) g << 1 << endl;
else g << 0 << endl;
break;
}
}
}
f.close();
g.close();
return 0;
}