Cod sursa(job #1795544)
Utilizator | Panaete Adrian proflaurian | Data | 2 noiembrie 2016 17:19:17 |
---|---|---|---|
Problema | Hashuri | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.8 kb |
#include <fstream>
#include <vector>
using namespace std;
ifstream f("hashuri.in");
ofstream g("hashuri.out");
const int p=100003;
int n,h,x;
vector<int> v[p];
int main()
{
f>>n;
for(;n;n--)
{
f>>o>>x;
h=x%p;
for(it=v[h].begin();it!=v[h].end();it++)
if(*it==v)
break;
if(o==1)
{
if(it==v[h].end())
v[h].push_back(x);
}
else
if(o==2)
{
if(it!=v[h].end())
{
*it=v[h].back();
v[h].pop_back();
}
}
else
if(it==v[h].end())
g<<"0\n";
else
g<<"1\n";
}
return 0;
}