Cod sursa(job #2554845)
Utilizator | Data | 23 februarie 2020 14:29:04 | |
---|---|---|---|
Problema | Hashuri | Scor | 50 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.88 kb |
#include<fstream>
#include<vector>
using namespace std;
ifstream fin("hashuri.in");
ofstream fout("hashuri.out");
int n,i,op,x,rest;
vector<int>r[666014];
int main()
{
fin>>n;
for(i=1; i<=n; i++)
{
fin>>op>>x;
rest=x%666013;
int dim=r[rest].size();
if(op==1)
r[rest].push_back(x);
else if(op==2)
{
for(int j=0; j<dim; j++)
if(r[rest][j]==x)
{
swap(r[rest][j],r[rest][r[rest][dim-1]]);
r[rest].pop_back();
break;
}
}
else
{
bool found=false;
for(int j=0; j<dim; j++)
if(r[rest][j]==x)
{
found=true;
}
fout<<found<<"\n";
}
}
}