Cod sursa(job #2746629)
| Utilizator | Data | 28 aprilie 2021 10:13:44 | |
|---|---|---|---|
| Problema | Hashuri | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 1.23 kb |
#include <iostream>
#include <fstream>
#include <vector>
using namespace std;
ifstream f("hashuri.in");
ofstream g("hashuri.out");
const int mod=666013;
int n;
vector <int> v[mod];
int main()
{
unsigned int x,op;
int key;
bool found=false;
f>>n;
for(;n;--n)
{
f>>op>>x;
key = x%mod;
if(op==1)
{
found=0;
for(unsigned int i: v[key])
if(i==x)
{
found=1;
break;
}
if(!found)
v[key].push_back(x);
}
else if(op==2)
{
for(int i=0; i<v[key].size(); ++i)
{
if(v[key][i]==x)
{
v[key][i] = v[key][ v[key].size() -1];
v[key].pop_back();
break;
}
}
}
else
{
found=0;
for(unsigned int i: v[key])
if(i==x)
{
found=1;
break;
}
g<<found<<'\n';
}
}
g.close();
return 0;
}
