Cod sursa(job #2663438)
Utilizator | Data | 26 octombrie 2020 13:19:10 | |
---|---|---|---|
Problema | Hashuri | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.78 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream f("hashuri.in");
ofstream g("hashuri.out");
const int Mod = 100003;
vector<int> v[Mod];
int n,t,x;
int main()
{
f>>n;
for(; n; n--)
{
f>>t>>x;
vector<int>::iterator it;
int h=x%Mod;
for(it=v[h].begin(); it!=v[h].end(); it++)
if(*it==x)
break;
if(t==1)
{
if(it==v[h].end())
v[h].push_back(x);
}
else if(t==2)
{
if(it!=v[h].end())
{
swap(*it,v[h].back());
v[h].pop_back();
}
}
else if(it==v[h].end())
g<<"0\n";
else
g<<"1\n";
}
return 0;
}